Skip to content

Resolve and verify a merge conflict

≈ 20 minutesBeginner6 steps · 20 min estimated

Outcome. Read both sides of a conflict, choose a resolution on its merits, complete the merge, and verify the result — or abort cleanly.

Before you start: Branches and merging basics

The duration is an estimate of engaged work, not a timer — nothing here waits. Steps marked "Check" and "Practice" are verified in the browser; "Read" and "Lab" steps are yours to confirm.

  1. Read

    Why conflicts happen

    ≈ 3 min

    Read this and "A conflict, end to end". Identify what `<<<<<<< HEAD` means relative to the branch you are on.

  2. Predict

    Predict: are the markers the problem?

    ≈ 1 min

    A common shortcut, examined.

    You delete the `<<<<<<<`, `=======` and `>>>>>>>` lines from a conflicted file and run `git commit`. What happens?
    Why

    Markers are just text. Git tracks the conflict in the index, and only `git add <file>` (or `git restore --staged`/`git rm`) marks it resolved. Then the commit completes the merge.

  3. Practice

    Practice: resolve, stage, commit

    ≈ 7 min

    The check requires the *right* value, no markers, the rest of the file untouched, and a real merge commit.

    Scenario: Resolve a merge conflict — completes automatically when the simulator's check passes.

  4. Read

    Getting out of a conflicted merge

    ≈ 2 min

    Know the exit before you need it: `git merge --abort`.

  5. Lab

    Do it in a real repository

    ≈ 6 min

    Includes the abort step. Mark this step after the `grep` for markers prints "clean".

  6. Check

    Knowledge check

    ≈ 1 min

    The lesson's check.

    Completes when the knowledge check on that page has been attempted.

When you are done: Git rerere: stop resolving the same conflict twice. Once resolving is routine, the next thing to learn is how Git can remember a resolution — and when you should not let it.

How did this go?