Writing good commit messages
github.com
github.com
Why is better to write in that form?
See: http://stackoverflow.com/questions/3580013/should-i-use-past...
Also the past repeats: http://news.ycombinator.com/item?id=2079612
For a good laugh: http://whatthecommit.com/
It makes more sense to me that the trouble ticket ticket should be written in the imperative and the commit message should be past tense.
What happens if I apply commit X to my project? Will it "Fix bug 35035" or "Fixed bug 35035"?
Fix bug foo
I'm going to assume that there is a bug that exists in this release that the author intends to fix later. Kind of like a TODO, which is what it sounds like.A random example from Chromium project[1]. There you can compare to get a feeling, because they are using both forms.
[1] http://www.chromium.org/getting-involved/dev-channel/release...
It makes a lot of sense if you don't view DVCSes as a fancy history mechanism but as a patch management system. Here, take this bunch of patches. What will I do if I'll merge them? I'll fix X, add option Z and port Q to ARM. Now let's say I also want to backport some patches to a stable branch, I'll take one from this branch, some from others and I'll fix X, fix Y and fix Z, but on ARM nothing works without the ARM commit, so on that branch I'll port Q to ARM.
[1] http://git.kernel.org/?p=git/git.git;a=blob;f=Documentation/...
At first I misread your explanation of DVCS as a patch management system and was going to say that non-imperative forms of commit summaries would function similarly. Now I understand your point, and I thank you again for explaining a useful way to conceptualize what merging multiple git commits together actually accomplishes.
With a bit of revisionism it reads like a wizard's incantation:
fix bug! ::code that fixes bug::
add feature! ::code that adds feature::
add documentation! ::comments etc.::
After all, in an ideal world, every code change would simply be the execution of the whiteboard/pencil-and-paper/planning that precedes it.
If I run a log on a file, and each commit has a sentence, I am a happy man. But of course, I'm talking about work, not an open source project.
FYI: a more useful corporate standard is to reference a trouble ticket, although having a descriptive sentence certainly helps (when you can get your team to type anything at all, without a trigger to force it).
Too many times I work on legacy code that where one third or less of the contents have comments -- HUGE, flowery blocks, and the rest have NOTHING.
I'd much rather have a short sentence starting with a verb, and not "this method will endeavor to attempt to proceed to ..." :-)
In any case, the comment for a class or method (or whatever) should start with a quick, concrete one-sentence description of what it is or does -- preferably starting with a verb, as you said. If you want to elaborate later, great, but everything needs the one-sentence summary. If I could tell inexperienced programmers one thing, this would be a strong contender. (Other possibilities include "Write your programs in discrete pieces that you can test in isolation, as much as possible," and "Make it work before you make it fancy.")
Might be also good to see the summary line all the time - in the editor just to keep myself focused.
sys: commit message (issue XXX)
And in English titles never end with a period anyway.N.B.: Requiring complete sentences in one-line summaries isn't generally a good rule, here or elsewhere, unless you like space-wasting filler. In describing a $memberType of $objectType, "This $memberType $actionVerbs the $objectType's $relation $relatedThing." is unnecessarily verbose. And I say this as someone who generally writes only complete sentences in SMS messages.
This is aesthetic nonsense masquerading as objective advice, and it makes me want to doubt the rest of the items too (though honestly most of them seem fine). I never understand why people are so drawn to this kind of silliness. It's like arguing if there should be a space between "if" and "(" (and yes, I've seen people do that too).
That is fantastically useful.
*(Walks you through "hunks" (finer granularity than files) and asks if you want to stage them.)
Just a personal preference, but I strongly prefer being able to build (and test) every commit in the entire history.
https://www.destroyallsoftware.com/screencasts/catalog/sourc...
git add -p
git commmit
git stash
build && test
git stash pop
rinse && wash && repeatNo guidance on how many changes should make up one good commit (versus several)? No rules on referencing the issue tracker, or changes made by other contributors? No suggestions for when to put useful information (like "always do x when calling y()") in the commit or in a wiki or something?
[1] http://who-t.blogspot.com.au/2009/12/on-commit-messages.html
[1] http://gitready.com/advanced/2009/02/10/squashing-commits-wi...
https://en.wikipedia.org/wiki/Wikipedia:ES https://en.wikipedia.org/wiki/Wikipedia:ESL