If you’ve never thought about what you write in git commit messages, congratulations, I’m recommending another Thing You Have To Think About. A cursory search will reveal many opinions on what makes for a good git commit message, and what tense it should be written in. Personally, I write git commit messages in the imperative tense. Like this:
git commit -m "Fix bug"
Not like these:
git commit -m "Fixed bug" git commit -m "Fixes bug" git commit -m "bug go squash lol"
(These examples demonstrate tense only. Definitely include more information in the commit than “fix bug”).
I hadn’t really thought about using a consistent tense for commit messages until I was taught to. I find writing in the imperative tense a little unnatural. This is a benefit, because it forces me to think about what a code change does. It also tends to result in a more concise and informative message. Writing a concise commit message acts as a sanity check on whether I’m commiting a sensible unit of work. If I can’t describe what a commit does, maybe I’m making too many changes at once.
As in so many things, I suspect the benefit does not really arise from following a rule—in this case using the imperative tense—but from being thoughtful about what you are doing.
I find a readable commit log valuable. Not everyone uses git this way, and, well, do whatever works for you. It is very ok to include a longer message too, like
git commit -m "Fix bug" -m "Here is a long description of the context surrounding this fix, so that if anyone else should need to, they can understand it."
Each commit tells a little story. I don’t worry too much about tense in the longer message. Far more important is to be clear about the reason for the change, especially if the change is small but the reason is involved. An internet stranger provides a much better example of this in their post My favourite Git commit.
Thanks for reading. If you'd like words like these in your inbox, sign up below. Or just check this site occasionally. Or run, now, and never speak of this place. You do you.