/* Code-Comments */

May 04, 2019

Git Merge Strategies - Recursive - Theirs (and Ours)

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

The -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 theirs.

The inverse of theirs is 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.

Git merge strategy options & examples | Atlassian Git Tutorial Git - merge-strategies Documentation

Stephen Weiss

Thanks for reading! My name's Stephen Weiss. I live in Chicago with my wife, Kate, and dog, Finn.
Click here to see the archives of my weeks in review and sign up yourself!