Skip to content

Instantly share code, notes, and snippets.

@shanecelis

shanecelis/.gitmessage

Last active Apr 15, 2020
Embed
What would you like to do?
A nice git commit template from https://deepsource.io/blog/git-best-practices/
# feature: Add beta sequence.
# ^-----^ ^----------------^
# | |
# | +-> Summary in present tense sentence.
# |
# +-------> Type: binary, chore, doc, excise, feature, fix, hack, legal, refactor,
# style, or test.

README

Help yourself write semantic commit messages by adding this template to your git commit template:

# feature: Add beta sequence.
# ^-----^  ^----------------^
# |        |
# |        +-> Summary in present tense sentence.
# |
# +-------> Type: binary, chore, doc, excise, feature, fix, hack, legal, refactor,
#                 style, or test.

USAGE

You can adopt this template without any technical intervention. However, this README will show you how to add so that when git asks for a commit, it'll show something like this:

feature: Add Entropy() convenience method to ArrayTally class.

# feature: Add beta sequence.
# ^-----^  ^----------------^
# |        |
# |        +-> Summary in present tense sentence.
# |
# +-------> Type: binary, chore, doc, excise, feature, fix, hack, legal, refactor,
#                 style, or test.

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch master
# Your branch is up to date with 'origin/master'.
#
# Changes to be committed:
#	modified:   Maths/ArrayTally.cs

INSTALL

Create File

Copy and paste the above message to ~/.gitmessage or run one of these shell commands.

$ curl https://gist.githubusercontent.com/shanecelis/db3f348288be70e4de4e0f2493f4e3d1/raw/12141f0f2615946d21053ab8e3230a02d18797e5/.gitmessage -o ~/.gitmessage

OR

$ curl -L https://bit.ly/38uuG3C -o ~/.gitmessage; # Same as above with a shortened URL.

Set Template

$ git config --global commit.template ~/.gitmessage

Acknowledgments

This guide is really the synthesis of these three articles:

  1. the semantic commit messages by Jeremy Mack,
  2. popularized in this best practices article by Sanket on DeepSource, and
  3. the git commit template tip by Alex Wasik.
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.