Skip to content

Instantly share code, notes, and snippets.

@stash
Last active December 14, 2015 07:29
Show Gist options
  • Select an option

  • Save stash/5050907 to your computer and use it in GitHub Desktop.

Select an option

Save stash/5050907 to your computer and use it in GitHub Desktop.
Checking for merge conflicts without changing working copy
#!/usr/bin/env bash
set -eE
# adapted from http://stackoverflow.com/questions/501407/is-there-a-git-merge-dry-run-option/6283843#6283843
remote_branch=$1
git fetch origin $remote_branch >/dev/null
if git merge-tree `git merge-base FETCH_HEAD HEAD` HEAD FETCH_HEAD | egrep -q '<<<|>>>|changed in both'; then
echo "No merge conflict"
else
echo "Branch has merge conflicts with $remote_branch!"
exit 1
fi
@stash
Copy link
Copy Markdown
Author

stash commented Feb 27, 2013

Possibly doesn't detect deletions/moves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment