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.

How to Write a Good Git Commit Message | Git Best Practices
Need to edit a Git commit message? Learn how to write a good Git commit message, and how to Git change a commit message, using GitKraken Client and the CLI.

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

Want to Learn Network Automation?
Join our membership and get access to:
  • Full deep-dive course library (inc. Batfish, pyATS, Netmiko)
  • Code repositories inc. full course code, scripts and examples
  • 24x7 multi-vendor labs (Arista, Cisco, Juniper)
  • Private online community
  • Tech demos and sessions

Join Now ➜