Skip to content

Instantly share code, notes, and snippets.

@obihann
Last active August 29, 2015 14:22
Show Gist options
  • Save obihann/c8e83155fa9795f1e5fd to your computer and use it in GitHub Desktop.
Save obihann/c8e83155fa9795f1e5fd to your computer and use it in GitHub Desktop.
look for merge conflicts

Search for merge conflicts by using grep and the pattern '>>>>' which is common to VCS systems such as Git, SVN, and Perforce.

Default use recursively searches based on your current folder:

$ ./conflicts.sh
Checking for conflicts in *
I've got 99 problems but merge conflicts ain't 1  :)

Alternatively you can specify a specific folder

$ ./conflicts.sh -t development/js
Checking for conflicts in development/js/*
I've got 99 problems but merge conflicts ain't 1  :)
#!/bin/sh
TARGET="*"
while getopts f:t: opts; do
case ${opts} in
t) TARGET="${OPTARG}/*" ;;
esac
done
echo "Checking for conflicts in ${TARGET}"
CONS="$(grep -rl '>>>>' ${TARGET})"
if [ -z "$CONS" ]; then
echo "I've got 99 problems but merge conflicts ain't 1 :)"
else
echo "Uh Oh.... These guys are confused:"
echo "${CONS}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment