What .gitattributes merge=union etc. dispatches to.
Internal three-way merge driver invoked per-file. This is what merge=union and friends in .gitattributes dispatch to, called by git merge-index once for every conflicted path.
Plumbing-level, single-file merge: given three blob/mode/SHA triples (base, ours, theirs) and a path, write the merged result into the working tree and stage it (or report a conflict).
git merge-one-file <orig-blob> <our-blob> <their-blob> <path> <orig-mode> <our-mode> <their-mode>
# Actually invoked indirectly:
git merge-index git-merge-one-file -a
git merge-index -o git-merge-one-file <paths>...
| Flag | What it does |
|---|---|
(positional) orig-blob | SHA of the common ancestor blob, or empty string if absent |
(positional) our-blob | SHA of HEAD's version of the blob |
(positional) their-blob | SHA of MERGE_HEAD's version |
(positional) path | Working-tree path to write the merged result to |
(positional) modes | Three octal mode strings (orig, our, their); blank means missing |
git merge-index -a when finishing an index-level merge.gitattributes merge=text (the implicit setting)merge.<name>.drivergit merge-index -o git-merge-one-file -agit merge-index -o git-merge-one-file src/a.c src/b.cgit config merge.ourunion.driver 'cat %A %B > %A'echo 'CHANGELOG merge=ourunion' >> .gitattributesgit merge-index or just git merge instead.%O %A %B %L %P placeholders (ancestor, ours, theirs, marker size, path) - mirror that contract.text is implicit; defining merge.text.driver overrides Git's built-in three-way merge globally.Hit each option, then Check answers. Score is recorded; Next is always open.