Git & GitHub Interview Question #40

What is a three-way merge?

Remotes, Fetch, Pull, Push, Merge, Conflicts, Rebase & Stash Junior Beginner

Quick Interview Answer

A three-way merge combines two branch tips using their common ancestor as a third reference point. Git compares how each side changed relative to that ancestor and creates a merged result.

Detailed Explanation

A three-way merge combines two branch tips using their common ancestor as a third reference point. Git compares how each side changed relative to that ancestor and creates a merged result.

This is commonly required when both branches have progressed after diverging. If Git cannot automatically reconcile overlapping changes, it reports merge conflicts.

Code Example

git switch main
git merge feature/dashboard

# Inspect the resulting history
git log --oneline --graph --decorate