Skip to content
Please note that GitHub no longer supports Internet Explorer.

We recommend upgrading to the latest Microsoft Edge, Google Chrome, or Firefox.

Learn more
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time. Cannot retrieve contributors at this time
executable file 18 lines (16 sloc) 609 Bytes
# Prevent accidental commits using any of:
# NOCOMMIT, DO_NOT_COMMIT, etc.
#
# How to use:
# 1. Store in ~/.gitconfig.d/hooks/pre-commit
# 2. Make sure it has +x permission `chmod +x ~/.gitconfig.d/hooks/pre-commit`
# 3. Add it into global hooks `git config --global core.hooksPath '~/.gitconfig.d/hooks'`
DISALLOWED_WORDS='\(NO\|NO\(_\| \)\|DO\(_\| \)NOT\(_\| \)\)COMMIT'
if git commit -v --dry-run | grep -e "${DISALLOWED_WORDS}" >/dev/null 2>&1
then
echo "Trying to commit non-committable code."
git commit -v --dry-run | grep --color -C3 -e "${DISALLOWED_WORDS}"
exit 1
else
exit 0
fi
You can’t perform that action at this time.