Skip to content

Instantly share code, notes, and snippets.

@shanecelis
Last active February 13, 2023 07:37
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shanecelis/db3f348288be70e4de4e0f2493f4e3d1 to your computer and use it in GitHub Desktop.
Save shanecelis/db3f348288be70e4de4e0f2493f4e3d1 to your computer and use it in GitHub Desktop.
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