Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I use past or present tense in git commit messages? [closed]

I read once that git commit messages should be in the imperative present tense, e.g. "Add tests for x". I always find myself using the past tense, e.g. "Added tests for x" though, which feels a lot more natural to me.

Here's a recent John Resig commit showing the two in one message:

Tweak some more jQuery set results in the manipulation tests. Also fixed the order of the expected test results.

Does it matter? Which should I use?

like image 840
Skilldrick Avatar asked Aug 26 '10 22:08

Skilldrick


People also ask

Should commit messages be in present or past tense?

For me, the commit message is a log of what has been done to the code since the previous commit; and for a log, past tense makes a lot more sense. If you really think the commit message should be a set of instructions, then the imperative tense is the way to go.

Is it a good practice to use present tense in commit messages?

It is a good practice to use present tense in commit messages.

Should git commit be in past tense?

Originally Answered: Which tense to use in a git commit message(past/present) and Why? The most important thing to do is to be consistent with your teammates. If the project has been using past tense, continue to do so. If the project has been using present tense, continue to do so.

Why are git commit messages in present tense?

As I understand it, the present tense means that the commit itself fixes the issue, not the developer which could be implied by using the past tense -"the developer fixed the issue".


1 Answers

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.

like image 160
mipadi Avatar answered Oct 09 '22 20:10

mipadi