LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

git-merge-tree

Perform merge without touching index or working tree

TLDR

Preview merge result (modern mode, Git 2.38+)
$ git merge-tree [branch1] [branch2]
copy
Perform a three-way merge with explicit base (deprecated mode)
$ git merge-tree [base] [branch1] [branch2]
copy
Check for merge conflicts and show informational messages
$ git merge-tree --write-tree --messages [branch1] [branch2]
copy
Check if a branch can be cleanly merged (exit code 0 = clean, 1 = conflicts)
$ git merge-tree --write-tree --no-messages [branch1] [branch2]
copy

SYNOPSIS

git merge-tree [--write-tree] [options] branch1 branch2git merge-tree [--trivial-merge] base branch1 branch2

DESCRIPTION

git merge-tree performs a three-way merge without touching the index or working tree. It shows what a merge would produce, making it useful for previewing merges or performing scripted merge analysis.The modern mode (default since Git 2.38) automatically finds the merge base, writes a result tree object, and reports conflicts. The exit code indicates success (0) or conflicts (1). This makes it ideal for CI pipelines and automation scripts that need to check mergeability without modifying any files.The deprecated trivial-merge mode requires specifying the base commit explicitly and only handles trivial merges.

PARAMETERS

BRANCH1

First branch to merge.
BRANCH2
Second branch to merge.
BASE
Common ancestor commit (deprecated trivial-merge mode only).
--write-tree
Modern mode (default since Git 2.38): automatically finds the merge base and writes a result tree object. Reports conflicts via exit code and stdout.
--trivial-merge
Deprecated mode: reads three trees and outputs trivial merge results. Requires explicit base.
--[no-]messages
Write informational messages such as "Auto-merging" and CONFLICT notices. Default: included when conflicts exist.
--name-only
In the output, show only filenames instead of full merge details.
--allow-unrelated-histories
Allow merging branches that share no common history.
--merge-base commit
Specify a merge base instead of computing one automatically. With this option, branch arguments can be trees instead of commits. Incompatible with --stdin.
--stdin
Read commits to merge from standard input, one pair per line. Implies -z.
-z
Use NUL characters as line terminators instead of newlines (for scripting).

INSTALL

sudo apt install git
copy
sudo dnf install git
copy
sudo pacman -S git
copy
sudo apk add git
copy
sudo zypper install git
copy
brew install git
copy
nix profile install nixpkgs#git
copy

CAVEATS

Plumbing command primarily intended for scripting. Output format differs between modern and deprecated modes. Modern mode requires Git 2.38 or later.

SEE ALSO

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid