Skip to content

Instantly share code, notes, and snippets.

Forked from turbo/
Created December 16, 2020 09:24
Show Gist options
  • Save tonibardina/9290fbc7d605b4f86919426e614fe692 to your computer and use it in GitHub Desktop.
Save tonibardina/9290fbc7d605b4f86919426e614fe692 to your computer and use it in GitHub Desktop.
Git Commit Message Standard

Merged from and

General Rules

  • Commit messages must have a subject line and may have body copy. These must be separated by a blank line.
  • The subject line must not exceed 50 characters
  • The subject line should be capitalized and must not end in a period
  • The subject line must be written in imperative mood (Fix, not Fixed / Fixes etc.)
  • The body copy must be wrapped at 72 columns
  • The body copy must only contain explanations as to what and why, never how. The latter belongs in documentation and implementation.


This is an example of a complete commit message that adheres to this standard. Parts of this are optional, so read on.

Summarize changes in around 50 characters or less

More detailed explanatory text, if necessary. Wrap it to about 72
characters or so. In some contexts, the first line is treated as the
subject of the commit and the rest of the text as the body. The
blank line separating the summary from the body is critical (unless
you omit the body entirely); various tools like `log`, `shortlog`
and `rebase` can get confused if you run the two together.

Explain the problem that this commit is solving. Focus on why you
are making this change as opposed to how (the code explains that).
Are there side effects or other unintuitive consequences of this
change? Here's the place to explain them.

Further paragraphs come after blank lines.

 - Bullet points are okay, too

 - Typically a hyphen or asterisk is used for the bullet, preceded
   by a single space, with blank lines in between, but conventions
   vary here

If you use an issue tracker, put references to them at the bottom,
like this:

Resolves: #123
See also: #456, #789

Subject and Body

  • A body copy is not required for commits that are overly simple. If you find yourself repeating the subject line in the body copy, it's a good sign that the body might be superfluous.

To perform a simple commit, a single command if sufficient:

$ git commit -m"Fix my subject line style"

If you need to write copy, issue git commit. Git will now open your default text editor. To set a custom editor, use git config --global core.editor nano (in this example, nano is the editor).

Here's an example of a subject and body commit message:

Derezz the master control program

MCP turned out to be evil and had become intent on world domination.
This commit throws Tron's disc into MCP (causing its deresolution)
and turns it back into a chess game.

This makes browsing the git log easier:

$ git log
commit 42e769bdf4894310333942ffc5a15151222a87be
Author: Kevin Flynn <>
Date:   Fri Jan 01 00:00:00 1982 -0200

 Derezz the master control program

 MCP turned out to be evil and had become intent on world domination.
 This commit throws Tron's disc into MCP (causing its deresolution)
 and turns it back into a chess game.

You can view a shorter log, by restricting the output to the subject lines:

$ git log --oneline
42e769 Derezz the master control program

This provied an easy way to get a quick overview by means of reading the shortlog:

$ git shortlog
Kevin Flynn (1):
      Derezz the master control program

Alan Bradley (1):
      Introduce security program "Tron"

Ed Dillinger (3):
      Rename chess program to "MCP"
      Modify chess program
      Upgrade chess program

Walter Gibbs (1):
      Introduce protoype chess program

Use the Imperative

Inkeeping with the standard output of git itself, all commit subject lines must be written using the imperative:


  • Refactor subsystem X for readability
  • Update getting started documentation
  • Remove deprecated methods
  • Release version 1.0.0


  • Fixed bug with Y
  • Changing behavior of X

Very Bad

  • More fixes for broken stuff
  • Sweet new API methods
  • 42

Your commit subject line must be able to complete the sentence

If applied, this commit will ...

If it doesn't, it's non-conformant. The body may use any style you want.

Use the Body to Explain the Background and Reasoning, not the Implementation

Especially if the diff is rather large or extremely clustered, you can save all fellow developers some time by explaining why you did what.

Here's a perfect example:

commit eb0b56b19017ab5c16c745e6da39c53126924ed6
Author: Pieter Wuille <>
Date:   Fri Aug 1 22:57:55 2014 +0200

   Simplify serialize.h's exception handling

   Remove the 'state' and 'exceptmask' from serialize.h's stream
   implementations, as well as related methods.

   As exceptmask always included 'failbit', and setstate was always
   called with bits = failbit, all it did was immediately raise an
   exception. Get rid of those variables, and replace the setstate
   with direct exception throwing (which also removes some dead

   As a result, good() is never reached after a failure (there are
   only 2 calls, one of which is in tests), and can just be replaced
   by !eof().

   fail(), clear(n) and exceptions() are just never called. Delete

This is way easier to parse than the corresponding diff.

Subject Line Standard Terminology

First Word Meaning
Add Create a capability e.g. feature, test, dependency.
Cut Remove a capability e.g. feature, test, dependency.
Fix Fix an issue e.g. bug, typo, accident, misstatement.
Bump Increase the version of something e.g. dependency.
Make Change the build process, or tooling, or infra.
Start Begin doing something; e.g. create a feature flag.
Stop End doing something; e.g. remove a feature flag.
Refactor A code change that MUST be just a refactoring.
Reformat Refactor of formatting, e.g. omit whitespace.
Optimize Refactor of performance, e.g. speed up code.
Document Refactor of documentation, e.g. help files.

Subject lines must never contain (and / or start with) anything else. Especially not something that's unique to your system, like

  • [bug] ...
  • (release) ...
  • #12345 ...
  • jira://...
  • docs: ...
Copy link

Most people don't write very good commit messages. Putting pressure on them to follow these rules is not entirely helpful and makes it harder, by creating a disincentive to making any effort at all. I suggest that commit messages should follow these simpler rules:

  • Commit messages must have a subject line and may optionally have a description.
  • Use a description if you need to, or if the message takes up more than about two lines or 200 characters.
  • Use any style for the subject line that you are comfortable with, as long as it explains the purpose and nature of the change. In particular, don't worry about whether you use the indicative ('fixed failure to draw arrows on routes' ). Note that a message of the form 'fix failure to...' is not in fact imperative in mood, but uses a form of the infinitive, as shown by the fact that it can follow a phrase like 'this change will'. Noun phrases using gerunds are fine too: 'refactoring of the label drawing system'.
  • Refer by its number to any bug fixed by the change: 'fixes #123'.

I have used this system over many years, and for over eleven thousand changes, and it has served me well.

Copy link

Nandinituptewar commented Aug 1, 2023

Best suggestions for commiting a message in too simple words

Copy link

Awesome. 😎

Copy link

Greate. 🎁

Copy link

LTHF25 commented Apr 20, 2024

nice thankyou 👍

Copy link

Thank you for your support 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment