Seamerge

What is a three-way merge?

A three-way merge combines two versions of a file by comparing each of them with the version they both started from, the base. Git merges this way, and a three-way merge tool shows all three versions so you can see who changed what.

Updated 21 November 2026

Two versions are not enough

Say a teammate changed a file on their branch while you changed it on yours. Put the two versions side by side, and one line reads fee = 5 on their side and fee = 7 on yours. Which one is new? Perhaps you raised the fee, perhaps they lowered it, perhaps both of you changed it. Two versions cannot tell you, so a merge that only compares two versions would have to ask about every difference.

The base answers the question

The base is the version before either change. With it, each difference has an author:

BaseA, incomingB, yoursResult
title = "Cart"title = "Cart"title = "Cart"Kept: nobody changed it
fee = 5fee = 5fee = 7fee = 7: only B changed it
currency = "EUR"currency = "USD"currency = "EUR"currency = "USD": only A changed it
rounding = 2rounding = 3rounding = 3rounding = 3: the same change on both sides
limit = 10limit = 20limit = 30Conflict: both changed it differently

So the rules of a three-way merge are short:

  1. What neither side changed stays as it is.
  2. What one side changed takes that change.
  3. What both sides changed in the same way takes the change once.
  4. What both sides changed in different ways is a conflict, and a person decides.

A merge does not work word by word but in blocks of lines. Git treats changes that touch the same or neighboring lines as one place, so two edits close together can conflict even when they change different lines. In the table, think of each row as a place far enough from the others.

Where the base comes from

In Git, the base of a merge is the merge base: the last commit that both branches share. Git finds it on its own, and you can ask for it:

git merge-base main feature

Git then applies the rules above to every file that both branches changed. Most changes merge cleanly; only the conflicts are left for you.

The base in conflict markers

By default, the markers Git writes into a conflicted file show only the two sides. Git can add the base between them:

git config --global merge.conflictStyle zdiff3

zdiff3 needs Git 2.35 or later; diff3 works in older versions. The conflict from the table then reads:

<<<<<<< HEAD
limit = 30
||||||| 3f2a1c0
limit = 10
=======
limit = 20
>>>>>>> feature

Your side comes first, then the base after |||||||, then the incoming side. It works, but it gets hard to read when a conflict spans more than a few lines.

A three-way merge in Seamerge

A three-way merge tool lays the versions out next to each other. Seamerge, a free merge tool for the Mac, shows A, the incoming side, the base and B, your side, above the result. Bands in the seams join the blocks that belong together. Blocks that only one side changed are taken for you; a conflict stays open, ringed in red, until you take A, B, both, or write the block yourself.

The Seamerge merge window: the incoming side, the base and your side above, the result below. Bands connect the blocks that belong together, unchanged lines are folded, and each block of the result has a decision bar.
The incoming side, the base and your side above the result.

To see what the base adds, hide it with Hide Base ⌥⌘B: A and B are then compared with each other directly, as in a merge without a base.

Resolve Git merge conflicts on a Mac walks through a merge step by step.