Journeys · Git · L1

Merge and rebase

Two ways to join diverged work. Same files at the end, different history.

✓ Validated on Git 2.43.0 · Run 1 · 2026-11-21Preview

The 30-second answer

When one branch has nothing of its own, git merge only moves it forward: a fast-forward, no new commit. When both moved on, git merge writes a merge commit with two parents. git rebase instead copies your branch's commits onto the other branch, one by one. The copies keep the author and the change, but get a new parent, a new committer date and new ids. The old commits are not changed. Both ways end with the same tree. A merge keeps both lines in the history; a rebase leaves one straight line.

Mental model

Two cooks change the same recipe book on different days. A merge staples both versions together with a new page saying this edition joins those two. A rebase rewrites one cook's pages on top of the other's, in order, as if they had been written later.

Where the analogy breaks

A rewritten page in a real book replaces the old one. Git's rebase writes new commits and leaves the old ones in place, still in the object store and the reflog. Anyone who has the old ones still has them.

🔒 Free account

Sign up free to play this journey

A free account unlocks every scenario, journey and exam, and saves your progress. No payment, ever.