git merge strategies - recursive - theirs (and ours)

2019-05-04

 | 

~1 min read

 | 

180 words

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



Hi there and thanks for reading! My name's Stephen. I live in Chicago with my wife, Kate, and dog, Finn. Want more? See about and get in touch!