Created
April 11, 2017 21:00
-
-
Save swape/8dc286fc067ed7c8180cddc5501110eb to your computer and use it in GitHub Desktop.
pre-commit script to prevent merge markers from being committed
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 | |
## pre-commit script to prevent merge markers from being committed. | |
## filename: .git/hooks/pre-commit | |
changed=$(git diff --cached --name-only) | |
if [[ -z "$changed" ]] | |
then | |
exit 0 | |
fi | |
echo $changed | xargs egrep '[><]{7}' -H -I --line-number | |
## If the egrep command has any hits - echo a warning and exit with non-zero status. | |
if [ $? == 0 ] | |
then | |
echo "\n\nWARNING: You have merge markers in the above files, lines. Fix them before committing.\n\n" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment