Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

feat: add hat wobble
^--^  ^------------^
|     |
|     +-> Summary in present tense.
|
+-------> Type: chore, docs, feat, fix, refactor, style, or test.

More Examples:

  • feat: (new feature for the user, not a new feature for build script)
  • fix: (bug fix for the user, not a fix to a build script)
  • docs: (changes to the documentation)
  • style: (formatting, missing semi colons, etc; no production code change)
  • refactor: (refactoring production code, eg. renaming a variable)
  • test: (adding missing tests, refactoring tests; no production code change)
  • chore: (updating grunt tasks etc; no production code change)

References:

@YelemyahM

This comment has been minimized.

Copy link

YelemyahM commented Oct 15, 2018

Thanks it's very useful

@codebender828

This comment has been minimized.

Copy link

codebender828 commented Dec 7, 2018

Thanks. Good stuff

@Keftaa

This comment has been minimized.

Copy link

Keftaa commented Jan 9, 2019

Thanks

@lwwcas

This comment has been minimized.

Copy link

lwwcas commented Jan 15, 2019

Starting today, I'll start using it, thanks

@kevinjalbert

This comment has been minimized.

Copy link

kevinjalbert commented Jan 28, 2019

Wanted to drop this here as well: https://www.conventionalcommits.org

@tobyokeke

This comment has been minimized.

Copy link

tobyokeke commented Mar 15, 2019

thanks.

@keymusicman

This comment has been minimized.

Copy link

keymusicman commented Mar 23, 2019

How about intermediate commits? For example, a big feature that has not been completed by the moment but should be commited and pushed. How is it better to write such commit message?

@YourSouLi5Mine

This comment has been minimized.

Copy link

YourSouLi5Mine commented Apr 5, 2019

@keymusicman you can use wip for work in progress

@marinoguerieri

This comment has been minimized.

Copy link

marinoguerieri commented Aug 6, 2019

Thanks

@HoracioEspinosa

This comment has been minimized.

Copy link

HoracioEspinosa commented Sep 25, 2019

Thanks, i made a commit-msg hook with your semantic, thanks a lot

#!/bin/sh

branch="$(git rev-parse --abbrev-ref HEAD)";
commit_regex='((CDW-)([1-9][0-9])|((feat|fix|chore|refactor|style|test|docs)(((\w{0,15})))?))(:.\S.*)';
error_msg="Aborting commit. Your commit message format is invalid, please check the references."
commit_message="$1";

if ! grep -iqE "$commit_regex" <<<"${commit_message}"; then
echo "$error_msg" >&2
exit 1
fi

if [ "$branch" = "master" ]; then
echo "You can't commit directly to master branch"
exit 1
fi

if [ "$branch" = "develop" ]; then
echo "You can't commit directly to develop branch"
exit 1
fi

Captura de Pantalla 2019-09-25 a la(s) 10 05 57

You can test this regex expression here

@wirths

This comment has been minimized.

Copy link

wirths commented Nov 7, 2019

Thanks :-)
conventionalcommits.org is heavily inspired by Angular´s commit rules:
https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#commits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.