Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mudrd8mz
Created May 29, 2012 13:49
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mudrd8mz/2828474 to your computer and use it in GitHub Desktop.
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
$ 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