Skip to content

Git Commit Message Guidelines

Aaron Hoffer edited this page Feb 14, 2019 · 3 revisions

Commit Message Style Guide

Commit Subject Line

  1. Begin the subject line with the name of the project, "DDF", followed by a dash, followed by the issue number
  • If the issue was created in JIRA, use the four digits of the issue number. For example, "DDF-1212"
  • If the issue was created in GitHub, prefix the four digits of the issue number with a zero. For example "DDF-01212"
  1. Separate subject from the body with a blank line
  2. Limit the subject line to 50 characters
  3. Capitalize the first word of the subject line
  4. Do not end the subject line with a period
  5. Use the imperative mood in the subject line

Commit Body Message

  1. Wrap the body at 72 characters
  2. Use the body to explain what and why vs. how. In particular, try to give some idea of the expected behavior this commit adds.

Example of a Good Commit Message

DDF-1234 Short (50 chars or less) summary of changes

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 an email 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); tools like rebase can get confused *if* you run
the two together.

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

Why Does This Matter?

  • Short, meaningful titles, followed by a blank line is used throughout git, GitHub, and other tools. Following this convention produces more readable output from logging tools and it makes things like annotating or blaming more readable. It also forces the developer to think critically and communicate clearly about the work done in each commit.
  • Good titles save the teams from extra reading and research into the purpose of a commit. A title should answer the question of "When this commit is applied, it will...". A commit does something. It is an action performed on the codebase, and the title should reflect the imperative nature of commits.
  • Ensures the body of a commit communicates the information other developers need. The how is in the diff, the commit message needs to explain what and why.

References