Writing good commit messages
There are many good resources and interesting articles online about how to write good messages when committing changes to a Git repository.
The post I often refer to is How to Write a Git Commit Message by Chris Beams.
In his post, he explains why good commit messages matter and gives these seven rules:
- Separate the subject from body with a blank line.
- Limit the subject line to 50 characters.
- 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.
I'd recommend reading the article to get the full context.
Rules two and six suggest lengths for the subject line and body which is another reason why I rarely use -m
when committing changes.
Whilst you can create multi-line commit messages on the command line, by opening it in my preferred editor (Neovim for me), I can see where the lines should end and be warned if I exceed them.
I can even include Chris' rules in my commit message template so I see them whenever I'm about to commit something.
This additional feedback helps me create my commit messages how I intend.
- Oliver