Skip to content

Instantly share code, notes, and snippets.

@jdelibas
Last active January 14, 2021 11:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdelibas/b0d1a8940acbbb617b3a8433fd491fdc to your computer and use it in GitHub Desktop.
Save jdelibas/b0d1a8940acbbb617b3a8433fd491fdc to your computer and use it in GitHub Desktop.
git commit message template
# <type>(<scope>): (If applied, this commit will) <subject>
# feat(login): add password enforcement rules
# |<---- Try To Limit Each Line to a Maximum Of 100 Characters ---->|
# <body>
# |<---- Try To Limit Each Line to a Maximum Of 100 Characters ---->|
# <footer>
# |<---- Try To Limit Each Line to a Maximum Of 100 Characters ---->|
# --- COMMIT END ---
# https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit
#
# Remember
# Do NOT capitalise the first letter in subject line
# Do NOT end the subject line with a period
# Do NOT exceed 100 character per line
#
# Do use the imperative mood in the subject line
# Do Separate subject from body with a blank line
# Do use the body to explain what and why vs. how
# Do use multiple lines with "-" for bullet points in body
#
# -- Type --
# Must be one of the following:
#
# feat: A new feature
# fix: A bug fix
# docs: Documentation only changes
# style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
# refactor: A code change that neither fixes a bug nor adds a feature
# perf: A code change that improves performance
# test: Adding missing tests or correcting existing tests
# build Changes that affect the build system, CI configuration or external dependencies (example scopes: gulp, broccoli, npm)
# chore: Other changes that don't modify src or test files
#
# -- Scope --
# The scope could be anything specifying place of the commit change. For example Compiler, ElementInjector, etc.
#
# -- Subject --
# The subject contains a succinct description of the change:
# use the imperative, present tense: "change" not "changed" nor "changes"
# don't capitalize first letter
# no dot (.) at the end
#
# -- Body --
# Just as in the subject, use the imperative, present tense: "change" not "changed" nor "changes".
# The body should include the motivation for the change and contrast this with previous behavior.
#
# -- Footer --
# The footer should contain any information about Breaking Changes.
# Breaking Changes should start with the word BREAKING CHANGE: with a space or two newlines. The rest of the commit message is then used for this.

Git commit message template

Example

  feat(login): add password enforcement rules
  
  Add checks for password enforcement:
    - must be longer than 5 chars
    - must have uppercase letter
    - must have lowercase letter
    - must have number

Installation

  • save .git_commit_message_template.txt to local machine
    • ~/, HOME, somewhere safe
  • run git config --global commit.template ~/.git-commit-template.txt
    • this will use the template whenever git commit is called
  • run git config --global commit.cleanup strip
    • this will prevent git from committing the template
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment