Skip to content

Instantly share code, notes, and snippets.

@mciuba
Last active August 29, 2015 13:56
Show Gist options
  • Save mciuba/8825377 to your computer and use it in GitHub Desktop.
Save mciuba/8825377 to your computer and use it in GitHub Desktop.
#!/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