Skip to content

Instantly share code, notes, and snippets.

@GMaissa
Forked from adeekshith/.git-commit-template.txt
Last active February 8, 2018 09:26
Show Gist options
  • Save GMaissa/f008b2ffca417c09c7b8 to your computer and use it in GitHub Desktop.
Save GMaissa/f008b2ffca417c09c7b8 to your computer and use it in GitHub Desktop.
Enforce good commit message practices across teams.
# |<---- Using a Maximum Of 50 Characters ---->|
# Explain why this change is being made
# |<---- Try To Limit Each Line to a Maximum Of 72 Characters ---->|
# Provide links or keys to any relevant tickets, articles or other resources
# Example: Github issue #23
# --- COMMIT END ---
# Type can be
# feat : new feature
# fix : bug fix
# wip : While working on a fix/feature
# refactor : refactoring production code
# style : formatting, missing semi colons, etc; no code change
# doc : changes to documentation
# test : adding or refactoring tests; no production code change
# uncat : uncategorized commit - will not be listed in changelog
# --------------------
# Remember to
# Capitalize the subject line
# Use the imperative mood in the subject line
# Do not end the subject line with a period
# Separate subject from body with a blank line
# Use the body to explain what and why vs. how
# Can use multiple lines with "-" for bullet points in body
# --------------------
#!/bin/sh
test -n "$(grep -iE '^(feat|fix|docs|test|refactor|style|uncat|wip) *:' ${1})" || {
echo >&2 "
ERROR: Please prepend the commit type to your commit message (ex: 'feat: my commit message').
Type can be
feat (new feature)
fix (bug fix)
wip (while working on a fix/feature)
refactor (refactoring production code)
style (formatting, missing semi colons, etc; no code change)
docs (changes to documentation)
test (adding or refactoring tests; no production code change)
uncat (uncategorized commit - will not be listed in changelog)
"
exit 1
}
@GMaissa
Copy link
Author

GMaissa commented Mar 22, 2016

To apply the template, save the .git-commit-template.txt file to your local machine and use

git config --global commit.template </path/to/file/.git-commit-template.txt>

To apply the git hook for commit message validation, copy the commit-msg file into your local air repository hooks directory (.git/hooks)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment