Write git commit messages properly
Redowan Delowar
November 11, 2021
Writing consistent commit messages helps you to weave a coherent story with your git history. Recently, I've started paying attention to my commit messages. Before this, my commit messages in this repository used to look like this:
With all the misuse of letter casings and punctuations, clearly, the message formatting is all over the place. To tame this mayhem, I've adopted these 7 rules of writing great commit messages:
The seven rules of writing consistent git commit messages
- Separate subject from body with a blank line
- Limit the subject line to 50 characters (I often break this when there's no message body)
- Capitalize the subject line
- Do not end the subject line with a period
- Use the imperative mood in the subject line
- Wrap the body at 72 characters
- Use the body to explain what and why vs. how
Now, after rebasing, currently, the commit messages in this repo look like this:
Further reading
Discussion in the ATmosphere