Skip to content

Instantly share code, notes, and snippets.

@davidvuong
Created April 12, 2016 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidvuong/a72bbdc2f481723721c7d32f048ef1ca to your computer and use it in GitHub Desktop.
Save davidvuong/a72bbdc2f481723721c7d32f048ef1ca to your computer and use it in GitHub Desktop.
Commit message guidelines

This gist describes my commit message structure. Its primarily based off AngularJS's commit message guidelines with a few alterations. You can check out their guidelines for more information here.

Overview

type(scope): [<id>] <message>
<new_line>
[<body>]

type(scope)

Commits belong to a pre-defined set of types. These types include:

  • feat - a new feature
  • copy - wording/text formatting changes
  • test - addition/update/removal of tests
  • rm - removal of something
  • fix - bug fix (whether it be UI, code or changes suggested in a PR)
  • refactor - change to code that neither fixes a bug or adds a new feature
  • style - UI changes
  • docs - documentation commits
  • chore - changes to the build process or auxiliary tools and libraries such as documentation generation
  • perf - no functional changes, just performance improvements

The scope refers to the section of the project you've made your changes against. For example, if I have an authentication API and my commit adds tests to that section of the codebase, the type(scope) might be test(auth).

Tagging your commits to use a type and scope make it super easy to navigate your commit logs. Having a type and scope also forces the developer to work in logical chunks, reducing the amount of really large commits.

[<id>]

This ID should reference the JIRA task ID. This is useful if you want your commit to point to a discussion thread on JIRA where the ticket has a bit more context. If the commit references multiple ids, I prefer to put those in the body. For example:

fix(auth): access_token not correctly parsed on request

(Closes,Related):
  - ID-555, ID-556

This is completely optional.

<message>

A short and concise description of your commit (all lowercase). Regarding the tense (past, present, future) - it doesn't really matter.

[<body>]

Sometimes the type, scope and message aren't enough to describe the commit. This is where you can talk a bit more about the commit. The message body is free flow text. I usually just use dot points but you're free to do whatever you like here.

Message lengths

Here's a StackOverflow post on commit message lengths. TL;DR As long as you stay within the "{50,72}~ish" range then you're golden.

Examples

feat(login): add link to forgot-password page
fix(auth): passwords were being truncated at 72 chars
fix(home): PR #14 fixed according to PR comments
copy(support)
style(*): change font across entire app
syntax(components+containers): make eslint compliant
refactor(client.views): convert components to pure fns
chore(webpack): update postcss-loader version
docs(readme): update contrib list
type(scope): my commit message title

Closes:
  - ID-15, ID-16, ID-17

- This commit now does X instead of Y because Y was causing problems with Z
- In addition, A has now been changed to B because we don't want users
  to mess up C because D, E, F, G...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment