Q:

How to specify a git merge "ours" strategy with .gitattributes for deleted files?

I have 2 branches in my project: A (master) & B. In branch B some of the files that are in master have been deleted. I want to avoid merge conflicts when there are changes in master to files that have been deleted in B.
I have added the files to .gitattributes, e.g.
README.adoc merge=ours

For my merge driver I have
[merge "ours"]
name = Always keep mine during merge
driver = true

However I still get conflicts and I can't figure out what I'm doing wrong.
git merge master
CONFLICT (modify/delete): README.adoc deleted in HEAD and modified in master. Version master of README.adoc left in tree.

What am I doing wrong? I have run git check-attr and it shows
README.adoc: merge: ours

I've also tried GIT_TRACE=2 but it provides no useful info; it only tells me where it is getting the binaries from.

A:

A modify/delete conflict is a high level conflict.  Merge drivers, defined in .gitattributes, are used only for solving low level conflicts: the merge driver is used only when the file (a) exists in all three versions (base and both branch tips) and (b) differs in all three versions.  Here, the file exists in two versions—base and one branch tip—and differs in those two versions, but the third version is simply deleted entirely, and the merge driver is never invoked.
For the recursive, resolve, and subtree strategies, high level conflicts always result in a merge conflict and a suspended-in-mid-process merge.  High level conflicts simply never occur in the ours strategy (-s ours, very different from the -X ours extended-option) as it looks only at the current tree.  High level conflicts in octopus are (I think) fatal: the octopus merge is aborted entirely.2

I want to avoid merge conflicts when there are changes in A to files that have been deleted in B.

To do this, you must write a merge strategy.  This is hard.1  See my answer to git "trivial" merge strategy that directly commits merge conflicts.

1The main evidence I have for "hard" is the fact that Git comes with those five strategies—resolve, recursive, ours, octopus, and subtree—and despite well over a decade of development, Git still has only those five strategies.
2I never actually do octopus merges, so my experience here is limited.

