One good article on commit message is How to Write a Git Commit Message.
Its rule n° 5 indeed recommends using imperative mood.
The imperative can sound a little rude; that's why we don't often use it. But it's perfect for git commit subject lines.
One reason for this is that git itself uses the imperative whenever it creates a commit on your behalf.
In the case of your topic, a simple "Doesn't add xxx" is enough to complete the first part of your commit (the "positive statement", in imperative).
Answer from VonC on Stack OverflowOne good article on commit message is How to Write a Git Commit Message.
Its rule n° 5 indeed recommends using imperative mood.
The imperative can sound a little rude; that's why we don't often use it. But it's perfect for git commit subject lines.
One reason for this is that git itself uses the imperative whenever it creates a commit on your behalf.
In the case of your topic, a simple "Doesn't add xxx" is enough to complete the first part of your commit (the "positive statement", in imperative).
I assume that you are trying to decide whether
Don't add hashing #1
or
Didn't add hashing #2a
Doesn't add hashing #2b
is imperative. This is really an English grammar question. But to answer it, we first need to turn the contractions back into their full forms:
Do not add hashing #1
(It) did not add hashing #2a
(It) does not add hashing #2b
The first of these is an instruction or command ... telling people not to add hashing. That is imperative.
The second two are simple statements of fact about the commit. They are saying that the commit does not or did not add hashing. This is not a direction or a command to anyone, therefore it is not imperative. (Either "does not" or "did not" is correct. It depends on whether you interpret the message in time-frame of the person writing it or the person reading it.)
By that analysis, the #1 and #2 forms would clearly mean very different things in a commit message. It is far more important that your commit messages should say what you actually mean, than that they should conform to some stylistic rules or conventions.
However ...
I'm still not totally clear about the way git commit messages are supposed to be written.
There is no single definitive authority on that topic. My recommendation would be not to sweat tears over it. Do what feels right to you. If people complain, ask them to explain in detail what you have done wrong, and try to learn. (Bear in mind that some people are never satisfied.)
Should I use past or present tense in git commit messages? - Stack Overflow
version control - Why is it preferred to write a commit message in present tense/imperative mood? - Software Engineering Stack Exchange
Commit message examples in book not using imperative mood
What % of Git commit messages use the imperative mood?
Videos
The preference for present-tense, imperative-style commit messages comes from Git itself. From Documentation/SubmittingPatches in the Git repo:
Describe your changes in imperative mood, e.g. "make xyzzy do frotz" instead of "[This patch] makes xyzzy do frotz" or "[I] changed xyzzy to do frotz", as if you are giving orders to the codebase to change its behavior.
So you'll see a lot of Git commit messages written in that style. If you're working on a team or on open source software, it is helpful if everyone sticks to that style for consistency. Even if you're working on a private project, and you're the only one who will ever see your git history, it's helpful to use the imperative mood because it establishes good habits that will be appreciated when you're working with others.
Your project should almost always use the past tense. In any case, the project should always use the same tense for consistency and clarity.
I understand some of the other arguments arguing to use the present tense, but they usually don't apply. The following bullet points are common arguments for writing in the present tense, and my response.
- Writing in the present tense tells someone what applying the commit will do, rather than what you did.
This is the most correct reason one would want to use the present tense, but only with the right style of project. This manner of thinking considers all commits as optional improvements or features, and you are free to decide which commits to keep and which to reject in your particular repository.
This argument works if you are dealing with a truly distributed project. If you are dealing with a distributed project, you are probably working on an open source project. And it is probably a very large project if it is really distributed. In fact, it's probably either the Linux kernel or Git. Since Linux is likely what caused Git to spread and gain in popularity, it's easy to understand why people would consider its style the authority. Yes, the style makes sense with those two projects. Or, in general, it works with large, open source, distributed projects.
That being said, most projects in source control do not work like this. It is usually incorrect for most repositories. It's a modern way of thinking about a commits: Subversion (SVN) and CVS repositories could barely support this style of repository check-ins. Usually an integration branch handled filtering bad check-ins, but those generally weren't considered "optional" or "nice-to-have features".
In most scenarios, when you are making commits to a source repository, you are writing a journal entry which describes what changed with this update, to make it easier for others in the future to understand why a change was made. It generally isn't an optional change - other people in the project are required to either merge or rebase on it. You don't write a diary entry such as "Dear diary, today I meet a boy and he says hello to me.", but instead you write "I met a boy and he said hello to me."
Finally, for such non-distributed projects, 99.99% of the time a person will be reading a commit message is for reading history - history is read in the past tense. 0.01% of the time it will be deciding whether or not they should apply this commit or integrate it into their branch/repository.
- Consistency. That's how it is in many projects (including git itself). Also git tools that generate commits (like git merge or git revert) do it.
No, I guarantee you that the majority of projects ever logged in a version control system have had their history in the past tense (I don't have references, but it's probably right, considering the present tense argument is new since Git). "Revision" messages or commit messages in the present tense only started making sense in truly distributed projects - see the first point above.
- People not only read history to know "what happened to this codebase", but also to answer questions like "what happens when I cherry-pick this commit", or "what kind of new things will happen to my code base because of these commits I may or may not merge in the future".
See the first point. 99.99% of the time a person will be reading a commit message is for reading history - history is read in the past tense. 0.01% of the time it will be deciding whether or not they should apply this commit or integrate it into their branch/repository. 99.99% beats 0.01%.
- It's usually shorter
I've never seen a good argument that says use improper tense/grammar because it's shorter. You'll probably only save 3 characters on average for a standard 50 character message. That being said, the present tense on average will probably be a few characters shorter.
- You can name commits more consistently with titles of tickets in your issue/feature tracker (which don't use past tense, although sometimes future)
Tickets are written as either something that is currently happening (e.g. the app is showing the wrong behavior when I click this button), or something that needs to be done in the future (e.g. the text will need a review by the editor).
History (i.e. commit messages) is written as something that was done in the past (e.g. the problem was fixed).
Another angle to consider is your commit's scope and your perspective (primarily for distributed VCS)... You can create all the local history you want, but it only becomes past tense once it's merged into the primary code branch.
In other words, the project lead needs to review it, and they apply my commit to "fix YYY". The bug itself only becomes "fixed" once someone authorative approves it and merges it in to the project.
For centralized systems, past tense seems more accurate, at least from this perspective.
When you use "Fixed XYZ" you can import it straight to your changelog. For example PHP Changelog.
18-Jul-2013
- Core:
- Fixed bug #65254 (Exception not catchable when exception thrown in autoload with a namespace).
- Fixed bug #65088 (Generated configure script is malformed on OpenBSD).
- Fixed bug #65108 (is_callable() triggers Fatal Error).
- Fixed bug #65035 (yield / exit segfault).
- Fixed bug #65161 (Generator + autoload + syntax error = segfault).
- Fixed bug #65226 (chroot() does not get enabled).
- hex2bin() raises E_WARNING for invalid hex string.
- OPcache:
- Fixed bug #64827 (Segfault in zval_mark_grey (zend_gc.c))...