Last active
December 14, 2015 07:29
-
-
Save stash/5050907 to your computer and use it in GitHub Desktop.
Checking for merge conflicts without changing working copy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Possibly doesn't detect deletions/moves.