Skip to content

Instantly share code, notes, and snippets.

@hhoopes
Created February 25, 2016 16:39
Show Gist options
  • Save hhoopes/c096204d632a0a4b5220 to your computer and use it in GitHub Desktop.
Save hhoopes/c096204d632a0a4b5220 to your computer and use it in GitHub Desktop.
Rules of thumb for good commit messages:
* Concise and consistent in length and form
* Explain the WHY of the change, not just WHAT changed
* Use your text editor to craft the message. It will simulate an email, a single concise subject line on the first line, a blank line, then a body with more explanatory detail
* "Imperative" subject lines use a verb as the first word, and can be interpreted as a command, e.g., "Fix mis-indentation in _git_stash()", "Factor out a helper to prepare a child process to run the pager"
How to create a convention with your team, perhaps in a DTR:
1. Discuss style, including markup syntax, wrap margins, grammar, capitalization, punctuation.
2. Discuss content, what to include, what not to include.
3. Discuss metadata. How shoudl things like issue tracking IDs and pull request numbers be referenced?
The syntax of a good message, from Chris Beams:
```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
6. Wrap the body at 72 characters
7. Use the body to explain what and why vs. how```
Good examples of commit messages:
* From Git itself: https://github.com/git/git/commit/f31b6cd4a28f36b5acc8ce5e39b221da000de5e7
* From Docker: https://github.com/docker/docker/pull/20686
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment