Skip to content

Instantly share code, notes, and snippets.

@dshendrickson
Last active January 3, 2018 06:15
Show Gist options
  • Save dshendrickson/2654cdaccd4094f9a76582ad9098d7bc to your computer and use it in GitHub Desktop.
Save dshendrickson/2654cdaccd4094f9a76582ad9098d7bc to your computer and use it in GitHub Desktop.

Proper Commit Messages

How to Write a Git Commit Message - Chris Beams

chris.beams.io/posts/git-commit/

The seven rules of a great 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. (Start the line with "Fix", "Add", "Change" instead of "Fixed", "Added", "Changed".
  6. Wrap the body at 72 characters.
  7. Use the body to explain what and why vs. how.

Source

How to Write a Git Commit Message - Chris Beams chris.beams.io/posts/git-commit/

Writing good commit messages

Good commit messages serve at least three important purposes:

  • To speed up the reviewing process.
  • To help us write a good release note.
  • To help the future maintainers...

5 Useful Tips For A Better Commit Message

Answer the following questions:

  1. Why is this change necessary? This question tells reviewers of your pull request what to expect in the commit, allowing them to more easily identify and point out unrelated changes.

  2. How does it address the issue? Describe, at a high level, what was done to affect change. Introduce a red/black tree to increase search speed or Remove , which was causing are good examples. If your change is obvious, you may be able to omit addressing this question.

  3. What side effects does this change have? This is the most important question to answer, as it can point out problems where you are making too many changes in one commit or branch. One or two bullet points for related changes may be okay, but five or six are likely indicators of a commit that is doing too many things.

Consider making including a link to the issue/story/card in the commit message a standard for your project. Full urls are more useful than issue numbers, as they are more permanent and avoid confusion over which issue tracker it references.

To take advantage of this sweet integration, first you’ll need to configure Git to use your editor (specifically, your editor’s command-line program, if it has one). Here, I’m telling Git to hand off commit messages to Atom:

$: git config --global core.editor "atom --wait"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment