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:
git log --oneline -5
d058a23 (HEAD -> master) bash strict mode
a62e59b Updating functool partials til.
532b21a Added functool partials til
ec9191c added unfinished indexing script
18e41c8 Bash tils
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:
git log --oneline -5
d058a23 (HEAD -> master) Employ bash strict mode
a62e59b Update functool partials til
532b21a Add functool partials til
ec9191c Add unfinished indexing script
18e41c8 Update bash tils
Reference
Recent posts
- SSH saga
- Injecting Pytest fixtures without cluttering test signatures
- Explicit method overriding with @typing.override
- Quicker startup with module-level __getattr__
- Docker mount revisited
- Topological sort
- Writing a circuit breaker in Go
- Discovering direnv
- Notes on building event-driven systems
- Bash namerefs for dynamic variable referencing