Skip to content

Instantly share code, notes, and snippets.

@avdgaag
Created November 12, 2013 09:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avdgaag/7427844 to your computer and use it in GitHub Desktop.
Save avdgaag/7427844 to your computer and use it in GitHub Desktop.
Git pre-commit hook to reject commits that contain Git conflict markers.
#!/bin/sh
# Add this to .git/hooks/pre-commit to reject any commits
# that contain Git conflict markers.
if git diff --cached --name-only --diff-filter=ACM | xargs grep -H -n -E '^(<|>|=|\|){7}' > /dev/null; then
echo "\033[31mWarning:\033[0m You have left some Git conflict markers in."
echo 'Your commit is bad and you should feel bad.'
echo
git diff --cached --name-only --diff-filter=ACM | xargs grep -H -n -E '^(<|>|=|\|){7}'
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment