DEV Community

Adam Rogers
Adam Rogers

Posted on


I’m on Team Good Commit Messages

There has been some debate on the value of good commit messages, and if we need them at all.

I’m on team good commit messages for a few reasons.

Good commit messages act as a sanity check for my changes

I cannot count the number of times I’ve been writing out a commit message, thought to myself “this is a stupid way to do this”, binned it all off and started again.

Good commit messages help me prove to myself that I know what I’m doing

If you understand something, you can explain it simply. If you can’t explain it simply, you don’t understand it. A good commit message is a simple explanation of the change, and I like to try to understand the changes I’m making to the code.

Good commit messages are integral to Git

Git is based on commits and commits have messages. Using Git effectively means working with commits, and commit messages the key to working with Git. It isn’t an intuitive tool, but it is a powerful one. Learning to use it efficiently is worth while, and good commit messages make working with Git easier.

Good commit messages give context for code

I have a plug-in for my text editor that makes it easy to view the commit associated with a given line of code, and the commit messages of the lines around it. The unfortunately named git blame command can often give more context than a comment in the code that is more likely to be out of date, or a link to an issue or other URL that is similarly tired or even expired.

In my experience, the value of good commit messages really becomes apparent when everyone on the team takes the time to write them. This is easiest to achieve if it’s just you, but wonderful to see when the whole team “gets it”.

This isn’t to say that I always write good commit messages. I don’t. Sometimes I have no idea what I’m doing, or I’m rushing a hot-fix into production, or a just can’t be bothered. I’m not a martyr.

But, given the time and space, I’m on Team Good Commit Messages.

Top comments (0)

We want your help! Become a Tag Moderator.
Check out this survey and help us moderate our community by becoming a tag moderator here at DEV.