We all know how important it is to write a commit message that neatly summarizes the changes being introduced. But the truth of the matter is that we programmers are forgetful. Because of this, I have put together a list of 5 killer tips for writing commit messages. The examples below use Git.
1. Terse is better than verbose.
Nobody likes a commit message that takes five minutes to read. Don’t translate each line of code into an English sentence. Instead, do your part to help cut down on wasted disk space by writing a very short summary of what the changes do:
git commit -m "Fixed stuff"
2. Think of others.
Instead of describing what the changes accomplish, describe the emotional impact of the commit. Try to put yourself in another person’s shoes. For example, if your changes introduce a lot of new features:
git commit -m "Overwhelming - tread softly"
Here is my personal favorite:
git commit -m "Horrific - the code you will soon see can never be unseen"
3. Use Unicode.
How many of your peers use Unicode characters in their commit messages? Remember, we want ours to stand out from the rest. Nothing stands out more than a Unicode character, in my opinion:
git commit -m "❤☂♞☎❄"
4. Be a different person.
There is no need to author each commit as the same person. Variety is the spice of life. Did you know that the
git commit command allows you to specify an author? Now you can do this:
git commit --author="Abe Lincoln
" -m "Free all the things!"
This comes in especially handy if you need to revert changes.
5. Use poetry.
Nothing shows attention to detail like poetry in a commit message. Because poems aren’t always short, an exception to tip #1 is permitted. Here’s an example:
git commit -m "there once was a man // who fixed the 'crash on load' // but this is not that programmer // and this is not that code"
If you really want to stand out, I suggest composing a haiku.