We have two branches X and Y that have been branched at this point:
test.txt
dir/a.txt
dir/b.txt
Now branch X introduces some changes into dir/a.txt and a commit is created. Branch Y makes a commit where dir/ gets deleted.
Then we want to merge X into Y. This will create a certain kind of “deleted-changed” conflict. Is it possible to instruct git to always “use ours” when it detects this specific conflict for the specific branch (Y) and a specific set of files (dir/*) ?
Read the section on merge strategies in the manual page. You can specify
-s oursor-s theirsto choose to use the version from one branch or another entirely. Or you can have it prefer to resolve conflicts using one or the other using the recursive merge with either ours or theirs recursive strategies. Note these are not the same things.In the above case, if you are on Y and you merge X with
git merge -s ours Xit will produce a result with changes from branch Y.