When it comes to version control and using Git, one thing I've always struggled with is knowing how to write good clean Git commit messages. For example, should I use title case or prefix the message with commit type (fix, feature etc.). The list goes on ... !
For those of you who are new to Git:
A Git commit is a snapshot of changes to a set of files and folders.
So I was pleased the other week when I discovered a well-written post (link below) from the good folks at GitKraken on precisely this. Today I want to highlight three key takeaways from this post that will help you quickly improve how you write your commit messages.
Tip 1 - Imperative Verb Form
Write your Git messages using imperative verb form by using the formula:
If applied, my commit will {INSERT COMMIT MESSAGE}
Example commit message: Update NTP server IP address
Tip 2 - General Grammar
- Avoid unnecessary capitalization
- Double-check your spelling
- Don’t end commit message summaries with punctuation
Example commit message: Change VLAN name for sales
Tip 3 - Commit Type
Start your commit message with the commit type. The traditional commit types are:
- Feat – feature
- Fix – bug fixes
- Docs – changes to the documentation like README
- Style – style or formatting change
- Perf – improves code performance
- Test – test a feature
Example commit message: Feat: Add new site-to-site VPN