Skip to content

Instantly share code, notes, and snippets.

@mikkkee
Last active August 29, 2015 14:23
Show Gist options
  • Save mikkkee/08c0ef811714d71ff97e to your computer and use it in GitHub Desktop.
Save mikkkee/08c0ef811714d71ff97e to your computer and use it in GitHub Desktop.
How to write idiomatic git commit messages

How to Write a Git commit message

Define a commit message convention

  1. Style. Markup syntax, wrap margins, grammar, capitalization, punctuation. Spell these things out, remove the guesswork, and make it all as simple as possible. The end result will be a remarkably consistent log that's not only a pleasure to read but that actually does get read on a regular basis.
  2. Content. What kind of information should the body of the commit message (if any) contain? What should it not contain?
  3. Metadata. How should issue tracking IDs, pull request numbers, etc. be referenced?

Seven rules of a great git commit message (well-extablished conventions)

There are well-extablished conventions as to what makes an idiomatic git commit message.

  1. Separate subject from body with a blank line
  2. Limit the subject line to 50 characters
  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

Notes

Useful git commands: git log, blame, revert, rebase, log, shortlog.

A properly formed git commit subject line should always be able to complete the following sentence:

  • If applied, this commit will your subject line here

For example:

  • If applied, this commit will refactor subsystem X for readability
  • If applied, this commit will update getting started documentation
  • If applied, this commit will remove deprecated methods
  • If applied, this commit will release version 1.0.0
  • If applied, this commit will merge pull request #123 from user/branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment