May 04, 2019
Often when I get a merge conflict, what I really want to do is defer to the master branch, so, if I’m on a branch and I want to merge in the master but suppress conflicts by deferring to the master branch, the way I could do that is:
$ git check out <branch> $ git merge master -s recursive -X theirs
-s is a flag for
strategies and the
-X is a “sub-flag” for the selected strategy (in the example above, that’s
recursive). In our case, since I want to defer to
master, I select
The inverse of
ours and is also possible:
$ git check out <branch> $ git merge master -s recursive -X ours
Related: if you aren’t sure before hand (and I’m never confident enough to just go straight away with a recursive strategy of ours or theirs — I look through the merge conflicts and then decide. To abort a merge, you can do
git merge --abort.
Written by Stephen Weiss who lives in Chicago with his wife, Kate, and dog, Finn. Follow him on Twitter!