TL;DR - How to Write Good Git Commit Messages

TL;DR - How to Write Good Git Commit Messages
Photo by Yancy Min / Unsplash

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

Subscribe to our newsletter and stay updated.

Don't miss anything. Get all the latest posts delivered straight to your inbox.
Great! Check your inbox and click the link to confirm your subscription.
Error! Please enter a valid email address!