Skip to main content
Module 4 · Lesson 2 of 415/34 in the course~17 min
Module lessons (2/4)

Three-way merge anatomy & branch cleanup

Lesson preview5 hands-on exercises readyGit & Modern Collaboration · Module 4 — Merging & Conflict Resolution

Understand how Git compares Base, Ours and Theirs to integrate diverged branches automatically.

What you'll learn in this lesson

  • Understand how Git performs an automatic 3-way merge using Base (merge-base), Ours (HEAD), and Theirs.
  • Predict when Git auto-merges cleanly (non-overlapping files or separate lines) vs pauses for conflict resolution.
  • Clean up merged feature pointers safely with git branch -d after integration.

Overview

Comparing ONLY the two branch tips (Ours vs Theirs) is hopelessly ambiguous: if src/auth.ts exists on feat/login and is missing on main, did feat/login just create it or did main just delete it?!

Git solves that riddle cleanly by looking backward to the common ancestor (Base) where both branches diverged (git merge-base main feat/login) and combining only changes since Base:

Sections covered in this lesson

  1. 1Why Three Trees Beat Two Trees
  2. 2Observe 3-Way Merges vs Rebases Visually
Pro Lesson · Module 4 — Merging & Conflict Resolution

Unlock "Three-way merge anatomy & branch cleanup" and the full Git & Modern Collaboration curriculum

Understand how Git compares Base, Ours and Theirs to integrate diverged branches automatically.

Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.

  • Instant access to all advanced modules in Git & Modern Collaboration plus 17 more courses
  • Hands-on browser exercises with automated test suites and solutions
  • 14-day money-back guarantee processed via Paddle.com

14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.