36

I've read all kinds of Git tutorials, including the official one, and they all seem to tell me it's good convention and practice to write Git commit notes in the present tense.

Why is that? What is the reasoning behind it?

Madara's Ghost
  • 158,961
  • 49
  • 244
  • 292
  • 2
    I would say that the commit message should describe what the commit does, not what the developer did. For instance, if you add a new feature to your project, "Add a new feature" indicates that this commit changes the project by adding a feature, whereas "Added a new feature" indicates that the developer did the actual change. Or at least this is how I feel about this :-) – BenC Dec 13 '12 at 14:02

2 Answers2

49

Git is a distributed VCS (version control system). Multiple people can work on the same projects. It'll get changes from many sources.
Rather than writing messages that say what a committer has done. It's better to consider these messages as the instructions for what is going to be done after the commit is applied on the repo.

So write a message like this

Fix bug#1234

Instead of

Fixed bug #1234

Treat the git log not a history of your actions, but a sequence descriptions of what all the commits do.

There is a big thread on hacker news about it. There you'll get many more reasons behind this convention.

Gust van de Wal
  • 4,519
  • 18
  • 39
Shiplu Mokaddim
  • 52,462
  • 12
  • 127
  • 180
  • You could write "bug#1234 has been fixed". – Daniel Hilgarth Dec 13 '12 at 13:57
  • 1
    That is **present** perfect tense. Still **present** – Shiplu Mokaddim Dec 13 '12 at 13:58
  • 2
    Although this particular commit message violates the second part of the convention that the summary should be in the imperative mood. E.g. "Fix bug #1234". – CB Bailey Dec 13 '12 at 13:59
  • 1
    That's right, it is present perfect simple. That's another tense than the present tense. – Daniel Hilgarth Dec 13 '12 at 13:59
  • Another possible message would be "Fixed bug#1234". That's what I actually would use, because - IMO - it conveys best what I *did*. – Daniel Hilgarth Dec 13 '12 at 14:01
  • Look carefully on `Fixed bug#1234`. Its an adjective clause provides the state of the commit. – Shiplu Mokaddim Dec 13 '12 at 14:02
  • @shiplu.mokadd.im: I am not sure I understand your comment. Care to elaborate a bit more? – Daniel Hilgarth Dec 13 '12 at 14:05
  • @DanielHilgarth I have changed my answer a lot. – Shiplu Mokaddim Dec 13 '12 at 14:10
  • @shiplu.mokadd.im: OK. I still don't understand your comment :-) – Daniel Hilgarth Dec 13 '12 at 14:13
  • 1
    According to English grammer `Fixed bug#1234` is a state which is adjective. As its more than 1 word it'd be adjective phrase (sorry I said clause last time). It means the total is not a sentence. When you make it a sentence, you can think of its tense. – Shiplu Mokaddim Dec 13 '12 at 14:17
  • 6
    @Daniel Although "Fixed bug #1234" does convey what you did, "Fix bug #1234" conveys what the patch does. The perspective behind using present tense is that the purpose of the message is to convey what the patch does, and not what the developer did. – William Pursell Dec 13 '12 at 18:54
  • 4
    @WilliamPursell: If it would convey what the patch does, shouldn't it read "Fix*es* bug #1234"? "Fix bug #1234" is an order, it tells the repository what to do, as others already explained in their answers. IMO that's counter-intuitive. – Daniel Hilgarth Dec 14 '12 at 09:48
  • 1
    Also, (this is why I like it) imperative mood is the shortest possible way to express the required information. "Bug XYZ is fixed" and "Fixed bug XYZ", vs. "Fix bug XYZ". It's the shortest! – Erik Nyquist Jul 19 '16 at 01:17
15

It's just a (relatively) common convention so that commits messages in a project read consistently. The advice for submitting patches to Git (for example) comes from Documentation/SubmittingPatches.

  • describe 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 behaviour.

As can be seen from the bracketed out subject, this convention removes the need for repeated - or alternatively implied - subjects for the commit verb that don't provide any useful benefit.

Albert Vila Calvo
  • 12,993
  • 4
  • 53
  • 63
CB Bailey
  • 648,528
  • 94
  • 608
  • 638