git-merge-tree - Linux


git-merge-tree is a Git command used to create an in-memory merge result without touching the working tree or index. It reads an arbitrary number of tree objects and merges them to produce a single combined tree object.


git merge-tree [-Q | -q] [-v] [-s <strategy>] <tree-ish> [<tree-ish>...]


  • -Q, -q: Suppress normal output; only print warnings and errors.

  • -v: Print all the merged paths.

  • -s : Merge strategy to use. Possible values:

    • recursive: Standard recursive three-way merge (default).
    • ours: Always favour our version of any conflicting paths.
    • theirs: Always favour their version of any conflicting paths.


1. Simple Merge

git merge-tree 4de764663b93c348872c5896be600d912c82d6c7 67336e861f3fb9bb1b4f4bca394f507dfb86e77d

This merges the trees at commit IDs 4de7... and 6733... into a single combined tree.

2. Merge with Strategy

git merge-tree -s theirs 71ad980e61de4f638d9a35917b88c4136e875371 92574d929bfa3beb498bb75a58da30227e71dea3

This merges the trees at 71ad... and 9257... using the "theirs" merge strategy, which always favours the version from the second parent.

Common Issues

  • Conflict Resolution: If a merge conflict occurs, the combined tree object will be incomplete and must be resolved manually by modifying the index and running git add.
  • Missing Trees: If any of the specified tree-ish arguments do not exist, the command will fail.


  • git commit -t: Create a commit from the combined tree.
  • git show / git diff: Inspect the combined tree.
  • git fsck and git verify: Verify the integrity and consistency of the combined tree.

Related Commands

  • git merge: Performs a merge operation with branches or commits.
  • git read-tree: Updates the index with the contents of a tree object.
  • git diff-tree: Shows the differences between two tree objects.