Home

Awesome

Git commit message

To write a great git commit message, take a look at these guidelines and suggestions.

Contents:

Top priorities

For the best git commit messages:

Begin with a short summary line

Begin with a short summary line a.k.a. message subject:

Continue with a longer description

Continue with a longer description a.k.a. message body:

Summary examples

Summary examples of good commit messages:

Summary keywords

We recommend these summary keywords because they use imperative mood, present tense, active voice, and are verbs:

Real-world examples

Real-world examples show how we use imperative mood, present tense, active voice, and verbs:

Use semantic versioning

We use semantic versioning for many of our projects:

Specifics for right and wrong

Capitalize the summary.

Finish the summary without a sentence-ending a period.

If the summary ends with an non-sentence-ending period, use it.

Use imperative mood: present tense, active voice, and lead verb.

Specifics for length

Keep the summary line within 50 characters.

Use a blank line after the summary line.

Use up to 72 characters per line for typical text for word wrap.

Use as many characters as needed for atypical text, such as URLs, output, formatted messages, etc.

Reasoning

We primarily care that our team communicates effectively with our shared understanding.

We secondarily like these verbs above because they're easy to read, easy to type, and clear in many cultures.

If you and your team prefer other words, that's fine too; use what works for you.

Reject these formats

We reject git commit message styles that put meta-information into the summary line.

Example:

We reject the git commit message style of projects such as Angular, Commitizen defaults, etc.

We reject using a ticket id number in the summary line.

We reject using a time tracking syntax in the summary line.

Optional: use contact email addresses

We sometimes have more than one person working on a commit. For example, we do do pair programming.

To keep track of this, we write a git commit message body that lists each person. We use the person's name and the email address. We use one person per line because this is easy to parse.

Co-authored-by: Alice Adams <alice@eaxmple.com>
Co-authored-by: Bob Brown <bob@example.com>
Co-authored-by: Carol Curtis <carol@example.com>

To make this easy, we use a git commit template.

Optional: use task tracking links

We sometimes connect a git commit to a task tracking system or web page that explains more. For example, we use GitHub, Trello, Jira, and many other bug tracking systems and project management software systems.

To keep track of these, we use a git commit message body that lists each URL, one per line, because this is easy to parse.

Example:

Add feature foo

See: https://github.com/user/repo/issues/789
See: https://jira.com/tasks/123
See: https://wikipedia.com/quicksort

If we want to provide link names, then we use Markdown links, such as:

See: [Request for help with sign in](https://github.com/user/repo/issues/789)
See: [Add feature foo](https://jira.com/tasks/123)
See: [Wikipedia Quicksort](https://wikipedia/quicksort)

To make this easy in practice, we use a git template that helps fill in this info.

Optional: use resource tracking metrics

We sometimes connect a git commit to a resource tracking system or metrics scripts. For example, we work on some projects where the project managers must keep track of work hours spent on a commit, or story point estimates per feature branch, or cost of hiring a developer to fix a bug.

To keep track of these, we use a git commit message body that lists each item, one per line, because this is easy to parse.

Example:

Add feature foo

Time: 7 staff hours
Cost: $700
Points: 7

Optional: use keywords, importance, references, etc.

We like to use commit message keywords to help us skim, search, and prioritize.

To keep track of these, we write a git commit message body that uses email header conventions.

Example:

Fix foo

Keywords: security, encryption, authentication
Importance: high
References: ...
Supersedes: ...
Obsoletes: ...
See-Also: ...

We use some of these to help our teams focus on the most important work.

Related links

Blog posts about how to write git commit messages:

Tools that help with git commit messages: