.gitmessage template src

~/.gitconfig

[commit]
  template = ~/.gitmessage

~/.gitmessage

Describe the commit in a short sentence fragment

This is an example commit message. The first line is a short summary. The second line is blank. The third line --- this line --- is a longer paragraph explaining the changes in the commit.

The first line should src

  • Be a short description of all of the changes in the commit.
  • Be between 50 and 72 characters.
  • Start with a capital letter (because it looks nicer).
  • Start with an infinitive verb that tells what the thing in the repository will do after the commit like “Show,” “Compute,” “Deallocate.” The first line should complete the sentence “After this commit, the application will…”. Try to avoid verbs that describe your action — more on that below.
  • Use the imperative mood in the subject line
  • NOT end with a period (because it looks nicer).
  • In big repositories, add context using a “[bracketed phrase]” at the start.

Imperative mood just means “spoken or written as if giving a command or instruction”. A few examples:

  • Clean your room
  • Close the door
  • Take out the trash

there should be a blank line

From the git commit manpage:

Though not required, it’s a good idea to begin the commit message with a single short (less than 50 character) line summarizing the change, followed by a blank line and then a more thorough description. The text up to the first blank line in a commit message is treated as the commit title, and that title is used throughout Git. For example, Git-format-patch(1) turns a commit into email, and it uses the title on the Subject line and the rest of the commit in the body.

The third line should

Your audience is junior members of your team.

The seven rules of a great Git commit message

Keep in mind: This has all been said before.

  • Separate subject from body with a blank line
  • Limit the subject line to 50 characters
  • Capitalize the subject line
  • Do not end the subject line with a period
  • Use the imperative mood in the subject line
  • Wrap the body at 72 characters
  • Use the body to explain what and why vs. how

For example:

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