DEPRECATED: See the gitlab engineering group for further details
We write our commit messages based on these guidelines proposed by Tim Pope:
- Use the english language
- Use a capitalized, short (~ 50 characters) subject line
- Prefix the subject line with metadata from the issue tracker, if available
- Use the present tense and imperative mood in the subject line
- Separate subject from body with a blank line, wrap the body at 72 characters
- Use the body to explain what and why vs. how
The subject line is a short summary of the changes introduced with a commit. Try to limit the subject to 50 characters. This is not a hard limit, but it improves readability for other developers when viewing the commit log. The GitHub and GitLab user interfaces are also aware of this limit and truncate longer messages with an ellipsis. Additional information such as technical details should go into the body.
If the commit relates to an issue in Jira, prefix the subject with the Jira issue-key followed by colon,
e.g. PROJECT-123:
. This helps to quickly lookup additional information in Jira.
Write your subject in the imperative: "Fix bug" and not "Fixed bug" or "Fixes bug."
This convention matches up with commit messages generated by commands like git merge
and git revert
.
The body is optional and used if a commit needs further explanation which cannot be expressed in the restricted subject line. Focus on why you are making this change as opposed to how (the code explains that).
Always separate the body from the subject with a blank line, as tools like git rebase
can get confused otherwise.
Wrap the body at 72 characters in order to keep the messages readable when using git log
.
PROJ-123: Refactored frontend build system. Removed some bower dependencies like fastclick, modernizr etc. Re-added all dependencies via npm and update grunt file.
The above example violates the following rules:
- The subject line is too long and contains technical details which should go into the body
- It uses the past tense instead of present tense and imperative mode
An improved version of the commit message may look like this:
PROJ-123: Refactor frontend build system
Remove the following bower dependencies and re-add them via npm:
* fastclick
* modernizr
* bootstrap-sass
* jquery.cookie
Update the gruntfile to respect new dependencies when building.