Skip to content

Instantly share code, notes, and snippets.

@asaaki
Created June 12, 2014 08:53
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 asaaki/5f092bdc36b0cf847937 to your computer and use it in GitHub Desktop.
Save asaaki/5f092bdc36b0cf847937 to your computer and use it in GitHub Desktop.
.git/hooks/pre-commit - Abort on conflict markers
#!/bin/sh
# Conflict markers
git diff --cached --diff-filter=ACMR | awk '/\+(<<<[<]<<<|>>>[>]>>>|===[=]===$)/ { exit 1 }'
CODE=$?
if [ "$CODE" != "0" ]; then
echo "COMMIT ABORTED: Conflict markers found." >&2
exit $CODE
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment