What would happen if I merged X into Y? Without touching either.
git merge-tree performs a trial three-way merge in memory and reports the resulting tree (and conflicts) without touching the index, working tree, or any branch. It answers 'would this merge cleanly?' for tooling and humans alike.
A pure function: (base, ours, theirs) -> (tree, conflict list). No refs move, no files change; modern hosted platforms call this to compute mergeability badges.
git merge-tree [--write-tree] [--merge-base=<commit>]
[--no-messages] [--name-only] [-z]
<branch1> <branch2>| Flag | What it does |
|---|---|
--write-tree | Modern mode: actually compute and write the merged tree, return its OID. |
--merge-base=<commit> | Override the auto-detected merge base. |
--no-messages | Suppress informational conflict messages; just emit the data. |
--name-only | Output only conflicting paths, not full conflict info. |
-z | NUL-terminate path output for safe scripting. |
git merge-tree --write-tree feature maingit merge-tree --write-tree --name-only -z feature maingit merge-tree --write-tree --merge-base=abc123 feature maingit merge-tree --write-tree --no-messages feature mainHit each option, then Check answers. Score is recorded; Next is always open.