Text 3-Way Merge

Merge a base file with two diverged edits — resolve conflicts visually

Free 3-way text merge tool that takes a common base plus two diverged versions and produces a merged result in your browser, auto-applying non-conflicting changes and marking real conflicts with Git-style markers. Nothing is uploaded. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

What is a 3-way merge?

A 3-way merge combines two versions of a file using their common ancestor (the base) as a reference. By comparing each side against the base, the algorithm can tell whether a change came from A, from B, or from both — which a simple 2-way diff cannot. This is exactly how Git merges branches.

Combine two independently edited versions of a file using their common ancestor as a reference — the same 3-way merge Git performs when joining branches. Changes made on only one side are applied automatically; regions both sides changed differently are flagged as conflicts with Git-style markers. Everything runs locally in your browser.

Why 3-way instead of 2-way

A naive 2-way diff cannot tell whether a difference means “A added a line” or “B deleted a line”. A 3-way merge resolves this by using the base (common ancestor):

  1. Diff base → A and base → B, line by line, using a longest-common-subsequence algorithm.
  2. Walk both diffs in lockstep over the base lines, classifying each region:
    • unchanged in both → keep the base text
    • changed in A only → take A
    • changed in B only → take B
    • changed in both, identically → take the shared result (no conflict)
    • changed in both, differently → emit a conflict

Conflicts are written with the familiar markers:

<<<<<<< A (mine)
A's version of the region
=======
B's version of the region
>>>>>>> B (theirs)

To resolve, edit the output to keep the side you want and delete the three marker lines.

Extended example: a config file edited by two engineers

Suppose two teammates forked the same base configuration file. Here is a realistic scenario:

Base:

host = localhost
port = 8080
debug = false
timeout = 30

Version A (your colleague switched the port and enabled debug):

host = localhost
port = 9090
debug = true
timeout = 30

Version B (you changed the host and increased the timeout):

host = api.internal
port = 8080
debug = false
timeout = 60

A 3-way merge produces:

  • host — only B changed it → take B’s api.internal.
  • port — only A changed it → take A’s 9090.
  • debug — only A changed it → take A’s true.
  • timeout — only B changed it → take B’s 60.

Result — no conflicts, everything merged automatically:

host = api.internal
port = 9090
debug = true
timeout = 60

Now suppose A had also changed host to staging.internal. That same line differs between A and B and didn’t come from the base, so it becomes a conflict block for you to resolve manually.

Common use cases

  • Code reviews gone async: two developers edited the same function without rebasing. Paste the last common commit as the base.
  • Document collaboration: two editors revised the same paragraph of a legal or policy document and the track-changes got out of sync.
  • Config management: merging two environment-specific overrides back into a shared config template.

Tips for clean merges

  • Use the exact version both edits diverged from as the base, not an approximation. Even one extra character in the base creates phantom conflicts.
  • Identical changes on both sides are never flagged — the algorithm merges them silently.
  • After resolving, search the output for <<<<<<< to confirm no conflict markers remain before copying.
  • For very large files, consider splitting them at logical sections and merging each section separately for easier conflict reading.