4 ms·
Commiting frequently also has a substantial cost of needing to think of a commit message. If you don't think of a commit message, you'll never be able to find
by londons_explore 6y ago
Commiting frequently also has a substantial cost of needing to think of a commit message.
If you don't think of a commit message, you'll never be able to find this version again. If you think up a message every 2 minutes, you'll quickly find you spend more time thinking of commit messages than writing code.
I wish there was some kind of auto generated commit message. Things like:
"Added function xyz()" or "Adjusted constant FOO to 27" or "Made lots of changes in file a.c,, b.c and c.c".
These could be auto generated, and then commits could happen in the background every time the code is compiled.
It would be nice for git to have some kind of "commit of commits" which allows a hierarchical representation of commits. Ie. the "Add new printscreen feature" could have as subcommits "Create print renderer" and "Hook up print UI".
- samb1729 6y ago> I wish there was some kind of auto generated commit message. Things like: > "Added function xyz()" or "Adjusted constant FOO to 27" or "Made lots of changes in file a.c,, b.c and c.c". I would argue that these are not good commit messages as they do not add information not already provided by the diff itself. Commit messages should communicate the intended effect of a change that has been made, rather than being a lossy compression of a sequence of keystrokes.
- londons_explore 6y agoIn which case I want a lossy summary of the diff... And it would be great if a tool could generate those for me...
- BatmanAoD 6y agoTry `git log -p <path(s)>`, which will show the sequence of diffs for only the specified set of files.
- FroshKiller 6y agoIf you don't already know the commit message before you start writing the code, maybe you should wait to write the code.
- formerly_proven 6y ago> It would be nice for git to have some kind of "commit of commits" which allows a hierarchical representation of commits. Ie. the "Add new printscreen feature" could have as subcommits "Create print renderer" and "Hook up print UI". These are usually called feature branches. > "Added function xyz()" or "Adjusted constant FOO to 27" or "Made lots of changes in file a.c,, b.c and c.c". These are very poor commit messages that don't add anything of value; any diff viewer will tell you the same immediately, so you might as well leave it blank. > Commiting frequently also has a substantial cost of needing to think of a commit message. In larger, private feature branches I'll use loads of "asdf" commits that I will later squash together. These are my "ok, so far so good" points to make figuring out where I broke something easier.
- davidelettieri 6y agoYou don't need to think about good commit messages. Just something that works for you and then rebase before pushing. That works for me at least
- jstimpfle 6y agoPeople are getting way to hung up about their commit history in most cases. If you're just experimenting, even "asdf" can be a totally fine commit message. And it shouldn't be hard to come up with something at least a little more descriptive in <20 seconds. Remember that in some situations, what you get from git is basically a glorified backup system. And that's valuable! You can edit the history later when it's required by somebody else working on the code. Or you can just not care. 99% of the value of your git repo should be in the most recent commit.
- amichal 6y agoLooking at other people's code I vastly prefer a feature branch with a summary name of the feature "new-checkout-flow" or whatever and then the commits as they where without squashing/rebasing. Mine tend to have quite a few commits cycling through: - Stub in [classes/models/etc] for checkout flow - Add basic test coverage - Fix my API for easier testing - Decouple foo from bar in new flow - New checkout flow mostly tested - New flow UI cleanup and add comments - Fix nasty [N+1/O(n^2)/etc] performance bug in new flow - New flow feedback from acceptance testing - New flow ready to merge - [And often enough/honestly] "WIP to share with..." or just "WIP" for work in progress, "Fixing bug in" or whatever reality there was. Going back at `git blame` etc 5 years later i can see from the branch names linked to the commit the why it was added and from the commit messages I can see something of at what point in the mental processing of designing/implementing that exact line made it it.
- jmelloy 6y agoI agree. I also think commit messages get more detailed the further along the process is, and the less code you change. “Added unit tests and stub out api” (50 files) vs “fix bug when files are added too quickly” (1 file, 3 lines)
- ugexe 6y agoOn the other side of the coin I hate looking at git blame to find a bunch of now irrelevant stuff, like fixes to code that were only ever in your branch. I don’t generally care about the discoveries you made along the way (at least not in commit form) unless I’m doing the review for it to go in the main branch, and even then it’s more of a curiosity than anything particularly relevant to software quality.
- jononor 6y agoPutting low-effort comments into temporary commits is OK. The one can use interactive rebase (git rebase -i) to squash and edit it into a coherent and clean history, when things get closer to finished.
- DevoidSimo 6y agoWhat's to stop you doing all these commits locally with uninformative messages, then squashing them when you push/PR with a better message?