29 Jun 2018

How to Write a Git Commit Message

Some words to start with

  • fix
  • rework
  • add
  • update
  • polish

Convention

Teams should first agree on a commit message convention:

  • Style: markup syntax, wrap margins, grammar, capitalization, punctuation
  • Content: What should it contain or not contain?
  • Metadata: Issue IDs, PR numbres etc.

The seven rules of a great Git commit message

  1. Separate subject from body with a blank line
  2. Limit the subject line to 50 characters

    → If you’re having a hard time summarizing you might be committing too many changes at once.

  3. Capitalize the subject line

  4. Do not end the subject line with a period

  5. Use the imperative mood in the subject line

  6. Wrap the body at 72 characters

  7. Use the body to explain what and why vs. how

    → Focus on making clear the reasons why you made the change - the way it things worked before the change (and what was wrong with that), the way they work now and why you decided to solve it the way you did.

The what and where

For example

Fix typo (what) in introduction to user guide (where).

Useful tools

git shortlog groups commits by user