Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save MakowskiHubert/d3485289707b1da0eb8ef0627a5aba31 to your computer and use it in GitHub Desktop.

Select an option

Save MakowskiHubert/d3485289707b1da0eb8ef0627a5aba31 to your computer and use it in GitHub Desktop.
Git pre-commit hook to prevent checking in non-resolved merge conflicts.
#!/bin/bash
# Check for merge conflicts
# Tested on Linux and Mac
# Simple check for merge conflics
conflicts=`git diff --cached --name-only -G"<<<<<|=====|>>>>>"`
# Something went wrong
if [[ -n "$conflicts" ]]; then
echo
echo "Unresolved merge conflicts in these files:"
for conflict in $conflicts; do
echo $conflict
done;
exit 1;
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment