# 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 · [Seamerge](https://www.seamerge.app/) › [Guides](https://www.seamerge.app/#guides)

## 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:

| Base | A, incoming | B, yours | Result |
|---|---|---|---|
| `title = "Cart"` | `title = "Cart"` | `title = "Cart"` | Kept: nobody changed it |
| `fee = 5` | `fee = 5` | `fee = 7` | `fee = 7`: only B changed it |
| `currency = "EUR"` | `currency = "USD"` | `currency = "EUR"` | `currency = "USD"`: only A changed it |
| `rounding = 2` | `rounding = 3` | `rounding = 3` | `rounding = 3`: the same change on both sides |
| `limit = 10` | `limit = 20` | `limit = 30` | **Conflict**: 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:

```sh
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:

```sh
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.](https://www.seamerge.app/images/seamerge-three-way-merge-window-light.png)

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](https://www.seamerge.app/resolve-git-merge-conflicts-mac.html) walks through a merge step by step.

## Download Seamerge

Free and open source, signed and notarized. Requires macOS 26.1 or later on Apple silicon.

- [Download for macOS](https://github.com/cykedev/seamerge/releases/latest)
- [Source on GitHub](https://github.com/cykedev/seamerge)

## More guides

- [Set up git mergetool and git difftool on macOS](https://www.seamerge.app/git-mergetool-difftool-mac.html): in one step from the app, or by hand with `git config`, and how to undo it.
- [Resolve Git merge conflicts on a Mac](https://www.seamerge.app/resolve-git-merge-conflicts-mac.html): what a conflict is, how to decide it block by block, and how to finish the merge.

---

Seamerge is free software under the [MIT License](https://github.com/cykedev/seamerge/blob/main/LICENSE). Not affiliated with Perforce, Git or Git-Tower. · [About, imprint and privacy](https://www.seamerge.app/about.html) · [Contact](https://www.seamerge.app/contact.html)
