Skip to content

Instantly share code, notes, and snippets.

@dln
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save dln/9483381 to your computer and use it in GitHub Desktop.

Select an option

Save dln/9483381 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Set up user-wide:
#
# 1) Copy this file to ~/.git_template/hooks/pre-commit
# 2) git config --global init.templatedir '~/.git_template'
# 3) New repos will initialize from template. Use 'git init' on existing repos to install manually.
#
# 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