credit to Sparkbox.
Never forget all this juicy knowledge! Set your commit message template to this wonderful example, by running:
git config --global commit.template "path/to/.gitmessage"
We use a strict style for all of our commit messages. The style we use helps ensure that our commits stay small and are easy to browse.
The Layout
<type>: <subject>
<body>
<footer>
The Title (the first line)
The title consists of the <type>
and the <subject>
.
Protip: Find yourself with an and in that commit title? Consider breaking the commit down.
git commit -p
is your friend!
Allowed Values for <type>
- feat (new feature)
- fix (bug fix)
- docs (changes to documentation)
- style (formatting, missing semi colons, etc; no code change)
- refactor (refactoring production code)
- test (adding missing tests, refactoring tests; no production code change)
- chore (updating grunt tasks etc; no production code change)
Subject
An imperative tone is also helpful in conveying what a commit does, rather than what it did. For example, use change, not changed or changes.
Funtip
Work hard, play hard! Consider prefixing your commit messages with a relevant emoji for great good.
- 🎨
:art:
when improving the format/structure of the code - 🐎
:racehorse:
when improving performance - 🚱
:non-potable_water:
when plugging memory leaks - 📝
:memo:
when writing docs - 🐧
:penguin:
when fixing something on Linux - 🍎
:apple:
when fixing something on Mac OS - 🏁
:checkered_flag:
when fixing something on Windows - 🐛
:bug:
when fixing a bug - 🔥
:fire:
when removing code or files - 💚
:green_heart:
when fixing the CI build - ✅
:white_check_mark:
when adding tests - 🔒
:lock:
when dealing with security - ⬆️
:arrow_up:
when upgrading dependencies - ⬇️
:arrow_down:
when downgrading dependencies - 👕
:shirt:
when removing linter warnings
Example:
:fire: feat (buybox): removed unused container elements
The Body
The body of the commit message should use a style similar to the one proposed in this article by tpope. The body, just like the subject, should use an imperative tone.
Inspired by Karma's commit style.
The Footer
Here you can reference issues and pull-requests that relate to your commit, like so:
closes #125
You can see the official Github doc for all the keywords to close issues and pull-requests.