Last active
August 29, 2015 13:56
-
-
Save mciuba/8825377 to your computer and use it in GitHub Desktop.
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
#!/bin/sh | |
# put this in file 'pre-commit' in .git/hooks | |
# file has to be marked as executable (+x) | |
#don't commit if FIXME was found in diff | |
exec 1>&2 | |
DONT_COMMIT_MARKER="FIXME" | |
if [ $(git diff --cached -G "$DONT_COMMIT_MARKER"|wc -l) != 0 ]; then | |
git --no-pager diff --cached -G "$DONT_COMMIT_MARKER" | |
echo | |
echo "ERROR: You're trying to commit a line containing $DONT_COMMIT_MARKER" | |
exit 1 | |
fi | |
#disable comitting in detached HEAD | |
if ! git symbolic-ref HEAD &> /dev/null; then | |
echo "You are in a detached head state! Commit has been blocked. (Use --no-verify to bypass this check.)" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment