Skip to content

Instantly share code, notes, and snippets.

@dperrymorrow
Created June 14, 2012 23:17
Show Gist options
  • Save dperrymorrow/2933611 to your computer and use it in GitHub Desktop.
Save dperrymorrow/2933611 to your computer and use it in GitHub Desktop.
git commit hooks
$ cat .git/hooks/pre-commit
#!/bin/sh
DIFF=`git diff HEAD`+`git diff --cached HEAD`
if [[ "$DIFF" == *"DO NOT COMMIT"* ]]
then
echo "Error; Attempt to commit a delta including the phrase 'DO NOT COMMIT'";
echo
echo "Use --no-verify to bypass this check."
echo
exit 1
fi
if [[ "$DIFF" == *"<<<<<<<"* ]]
then
echo "Error; Looks like you have a bad merge - due to the phrase '<<<<<<<'";
echo
echo "Use --no-verify to bypass this check."
echo
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment