Kelly Mears

Three-Way Merge

Combining two lines of work by comparing both against their common ancestor.

Version Control & Delivery1 min read185 words13 out · 15 in
also calledMergeMerge base

A three-way merge combines two divergent versions by comparing each against their common ancestor — the merge base. Knowing the ancestor is what lets the algorithm distinguish "this side changed it" from "that side changed it", and to combine non-overlapping changes automatically.

The merge base is why comparisons must be taken against the ancestor rather than against the current tip of the other branch. Diffing a branch against the current main attributes every change made on main since the branch was cut to the branch itself. The three-dot form of a diff selects the merge base and is almost always what is wanted.

Two things merges cannot do.

They cannot detect semantic incompatibility. Non-overlapping changes are combined without complaint even when they contradict each other; see Semantic Conflict. Conflict absence is not agreement.

They cannot resolve genuine overlap, which is a Merge Conflict and requires a human decision.

There is also a duplication hazard: two branches that each added the same content in the same place can merge with no conflict markers and produce it twice, which a compiler catches and a reader might not.

See also11

Rebase

Replaying a branch's commits onto a new base, producing new commits with the same changes.

Version Control & Delivery19 connections

Merge Train

Validating changes against the state they will actually merge into, in order, rather than in isolation.

Version Control & Delivery14 connections

Stacked Pull Requests

A chain of dependent changes, each reviewed separately and merged in order.

Version Control & Delivery12 connections

Regression

A previously working behavior that a change has broken.

Method23 connections

Version Control

A system recording the history of a project's files, enabling branching, merging, and recovery.

Version Control & Delivery26 connections

Trunk-Based Development

Everyone integrating into one shared branch continuously, with short-lived feature branches.

Version Control & Delivery20 connections

Continuous Integration

Automatically building and testing every change, so integration problems surface immediately.

Version Control & Delivery38 connections

Git Object Model

Git stores every version of a project as a graph of immutable objects named by the hashes of their contents, blobs for files, trees for directories, and commits for snapshots, which makes history tamper-evident and identical content free to store twice.

Version Control & Delivery12 connections

Staging Area

The intermediate snapshot in Git between the working files and the next commit, which lets a developer choose exactly which changes go into each commit, down to individual lines.

Version Control & Delivery15 connections

Fast-Forward Merge

The two basic ways Git joins branches, by sliding a branch pointer forward or by recording a new commit with two parents, and how the choice shapes a project's history.

Version Control & Delivery14 connections

Feature Branch

A branch created to develop one change in isolation before merging it back, a workflow that keeps the main line stable but grows riskier the longer the branch lives, since its divergence from everyone else's work compounds.

Version Control & Delivery16 connections

Linked from15