Git: Commit Message Conventions

Nikolas Begetis
2 min readDec 20, 2018

--

commit types (opinionate)

Check also the article directly in GithubGist

Every Time you finish with your code changes you have to follow this procedure:

  1. you should set in stage the changes you want to apply to your local branch
  2. commit your stage changes to your local branch of your local repository with a commit message

Later, you can also push the commit to your remote branch. Check here to find out how to do that.

The git commands for the above procedure are:

Format of the commit message

Any line of the commit message cannot be longer 72 characters! This allows the message to be easier to read on Github/Bitbucket/etc. as well as in various git tools.

Subject line

Subject line contains succinct description of the change.

Allowed [Issue-Code]

The Github/Bitbucket(Attlasian Jira)/etc. issue code to which this commit refers to.

Allowed <type>

  • feat (a new feature)
  • fix (bug fix)
  • perf (a code change that improves performance)
  • ci (changes to CI configuration files and scripts (e.g. kubernetes, swarm, jenkins, openshift, heroku))
  • build (changes that affect the build system or external dependencies (e.g. gulp, npm, yarn, .env variables))
  • docs (documentation only)
  • style (formatting, missing semi colons)
  • refactor (a code change that neither fixes a bug nor adds a feature)
  • test (code changes in tests)
  • chore (maintain (e.g. remove console.log, unnecessary comments))

Allowed <scope>

Scope could be anything specifying place of the commit change. For example $window, ./App, ./LoginView/style, etc.

<subject> text

  • start the subject text with WIP if the commit changes are still in progress and there maybe breaking errors (check the second example)
  • use the imperative, present tense: “change” not “changed” nor “changes”
  • don’t capitalize first letter
  • no dot/period(.) at the end

Message body (optional)

  • just as in subject use imperative, present tense: “change” not “changed” nor “changes”
  • includes motivation for the change and contrasts with previous behavior

Also check this link

Message footer (optional)

Referencing issues

Commit messages can automatically close/fix/resolve/reopen/etc. issues in Github/Bitbucket/etc. by using some fixed keywords, which you can find in Github, Bitbucket, etc.

For example: This closes #Issue-Code-34, reopens #Issue-Code-23, and refs #Issue-Code-42.

Examples

Example-1

Example-2

--

--