Should commit messages be written in present or past tense?

Version ControlCoding Style

Version Control Problem Overview


So which is it that you think is better and more intuitive?

Fixed the XXX bug in YYY
Fix the XXX bug in YYY
Fixes the XXX bug in YYY
Fixing the XXX bug in YYY

Please provide your rationales. Note I am asking from your general perspective, meaning you should not try to associate this with your preferred svn/cvs tools or programming languages, but rather think of it as something that should/can be applied to any tools and programming languages.

Version Control Solutions


Solution 1 - Version Control

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.

Solution 2 - Version Control

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).

Solution 3 - Version Control

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.

Solution 4 - Version Control

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.

Solution 5 - Version Control

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.

Solution 6 - Version Control

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.

Solution 7 - Version Control

I don't think it really matters. The purpose is to:

  1. Convey what is or was being done, so bugs can be found easier, problems can be reverted easier, and generally be able to maintain the project easier.

  2. Convey what tickets were fixed if any, so auditors (if they're used in you company can see what changes correspond to which tickets).

Lastly, if it's' already been fixed, "Fixing" doesn't make sense, and if you're still working on it, "Fixed" isn't correct.

Solution 8 - Version Control

"Fix bug X" is 2 characters shorter than "Fixed bug X".
And 3 shorter than "Fixing bug X".

From the point of view of writing-short-commit-messages, the present tense sometimes / usually saves a few characters?
Which I actually think matters a little little bit e.g. with Git's recommendation of less-than-50-chars-on-the-first-commit-message-line.
Also, less text --> done reading quicker?

Solution 9 - Version Control

A commit message describes why you wrote the code that is being committed.

"Fixed issue 3124", or "Fixes issue 3124" seems right because it says this code fixed|fixes issue 3124.

However, the grammar may also depend on why marks the bug as fixed. If you can mark the bug as fixed after committing, then "Fixed" is just fine, but if the bug is going to be marked as fixed by someone else after they verify your code, then "Fixes" may be more appropriate.

Solution 10 - Version Control

I think "Fixes XXX bug" makes more sense than "Fix XXX bug" if the reason for using the present tense is to "make it more descriptive of what the commit does" rather than what the committer did.

Solution 11 - Version Control

I think the most important answer to such a question is: Everybody should use what works for a specific project and keep it at least a tiny bit consistent.

While I see the advantages of using the present tense (and in fact stumbled upon this post because I’ve seen some present tense messages in open source projects), I probably never won’t use the present tense for my projects. It’s the recommended way for Linux and Git, and probably other bigger open source projects, but I honestly don’t care as long as I’m not part of these projects.

I’m an indie dev and I use the first line of a commit message for release notes while the description in the following lines gives me an idea about implementation details. It’s a user centric workflow compared to the present tense, developer based approach. I can save some time this way. It would be extremely unnatural to give my users instructions in the release notes. It’s my job to fix bugs and to add features. I have to save time, because I’m an indie. I don’t have a “release notes writer” in my team.

Use the rules of a project if they’re already established, but stay pragmatic, and do whatever will make your work easier or faster.

Solution 12 - Version Control

If it is a small commit I use present continuous:

> Fixing bug 304

or > Adding comments

If it is a big commit, I do more of a change log:

  • Fixes Bug 453, 657 and 324
  • Adding Expression syntax
  • Refactored the Operator class.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionHisView Question on Stackoverflow
Solution 1 - Version ControlRoger PateView Answer on Stackoverflow
Solution 2 - Version ControlcletusView Answer on Stackoverflow
Solution 3 - Version ControlTedPavlicView Answer on Stackoverflow
Solution 4 - Version ControlIvanView Answer on Stackoverflow
Solution 5 - Version ControlPhil HordView Answer on Stackoverflow
Solution 6 - Version ControlKen BloomView Answer on Stackoverflow
Solution 7 - Version ControlReverend GonzoView Answer on Stackoverflow
Solution 8 - Version ControlKajMagnusView Answer on Stackoverflow
Solution 9 - Version ControlParagView Answer on Stackoverflow
Solution 10 - Version ControltechnophyleView Answer on Stackoverflow
Solution 11 - Version ControlRafael BugajewskiView Answer on Stackoverflow
Solution 12 - Version ControltsterView Answer on Stackoverflow