Created
November 12, 2013 09:10
-
-
Save avdgaag/7427844 to your computer and use it in GitHub Desktop.
Git pre-commit hook to reject commits that contain Git conflict markers.
This file contains 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 | |
# 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