Merge conflict
What it is
A merge conflict occurs when Git cannot automatically combine changes from two branches because both modified the same lines of the same file (or one deleted a file the other edited). Git stops and asks a human to decide what the final content should be.
Why it exists
Git merges automatically by comparing the three versions involved — the common ancestor and the two branch tips. When the same line changed differently on each side, there is no unambiguous answer, so Git refuses to guess and surfaces the conflict for manual resolution.
Key ideas
- How it looks — conflicted files contain
<<<<<<<,=======,>>>>>>>markers showing the incoming vs. current content. - Resolution — edit the file to the correct content,
git addit, then complete the merge (or rebase). - Fast-forward vs. true merge — a fast-forward has no conflict because there’s no divergent history.
- Best practice — resolve quickly and keep branches short-lived; long branches multiply conflicts.
Exam notes
- Conflicts happen only on convergent edits to the same lines; Git auto-merges everything else.
- Resolution is a manual, human decision — this is why small, frequent merges (trunk-based) are favored.
- Knowing how to resolve markers (
<<<<<<</=======/>>>>>>>) and when to abort (git merge --abort) is a core skill.
Related
git · branching-strategy · pull-request
📘 Source: Microsoft Learn — Merge Conflict