Created
May 29, 2012 13:49
-
-
Save mudrd8mz/2828474 to your computer and use it in GitHub Desktop.
Git pre-commit hook that does not allow committing a change containing DONOTCOMMIT text
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat .git/hooks/pre-commit | |
#!/bin/bash | |
FOUND=$(git diff-index --cached -U0 HEAD -- | grep DONOTCOMMIT | wc -l) | |
if [[ $FOUND -gt 0 ]]; then | |
echo "pre-commit hook: DONOTCOMMIT detected, commit not allowed" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment