Reputation: 341
I want to merge branch release on branch master such that I resolve all conflicts in favor of master (ours) except for a particular folder for which I want resolve all in favor of release (theirs). Is there a clean way of doing this?
Basically I am trying to fix something messed up by earlier merges.
Upvotes: 0
Views: 57
Reputation: 30986
Let's say there are three folders foo/
, bar/
and fizz/
, and you are in favor of release
for fizz
and master
for the rest.
#you've encountered the conflicts during a merge
git checkout master -- . ':!fizz/'
git checkout release -- fizz/
git commit
. ':!fizz/'
means all except fizz/
. So foo/
and bar/
of master
are checked out. Likewise, fizz/
of release
is checked out. In the end, git commit
finishes the merge process.
Update:
As @torek 's comment says, the steps above works as -s ours
for subfolders (note that there is NOT -s theirs
). It ignores all the changes of "theirs". If what you want is to automatically pick our changes only for conflicting parts and just let it be if the merge is okay, then it should use something like git merge -X ours
and git merge -X theirs
, and don't run the commands in the answer. As @torek says, git merge-file --ours/--theirs
work.
Upvotes: 2