Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should commit messages be written in present or past tense? [closed]

People also ask

What tense to write commit messages in?

The commit message should be imperative, present tense because with git you or somebody else may end up doing rebase or cherry-pick and in that case, the commit may be used outside its original context.

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

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


I think of these messages as they appear to other developers. They don't yet have the changes applied, and there is the implicit question, "what will applying this changeset/patch do?" It will "Fix the XXX bug in YYY"!

For other verbs writing them as a command seems more natural, and works better if you have a specific goal up-front—you can literally write the commit summary along with up-front tests before the work is done.

I don't put a huge amount of weight on it, but for me this is the path of least resistance while maintaining consistentency.


I personally go with past tense ("fixed") since by the time I get to committing the bug is fixed (or I wouldn't be committing).


I prefer to see commit messages in present tense. That way the message describes what the diff does (because you might pull that diff or even that whole commit into a different branch). Thus, the commit message does not describe what it "did" do... It describes what the commit itself "does" do. So it should be in present tense.

Imagine looking at a diff in isolation and trying to decide whether you will apply it. It makes no sense for it to have a title in the past tense.


IMHO if you want it to be descriptive without need to consider the context, then "Fixed" is definitely the only right variant.

Regarding the intuitiveness - if I look at some changelog I will definitely understand that you mean the bug fixed as I know the context in which the word is used, but my brain will catch it much more quickly if the word is written in this self-specifying way.

"Fixing" is the worst choice IMHO as it can be interpreted not only as describing what the patch does (is for) but as a bug status as well which would mean that it is being worked at and is not yet solved.


Fix the XXX bug in YYY
Teach the XXX to be more ZZZ
Correct typos in javadoc

In general: {imperative verb} the {affected object} {optional qualifiers}

Imperative form fits all use cases when I'm considering a patchset.

  • What are you going to do here?
  • What does this patchset do?
  • Why was this patchset created? (to fix the xxx bug...)
  • I need to fix the xxx bug in yyy. Is there a commit on another branch that does this already?

Regardless of your choice, I find consistency helps readability immensely. Pick one and stick with it.


I think that writing about the current commit in present tense is a good idea, because it makes it more clear when you refer to prior commits in the past tense.