Skip to content
rajin

18Understanding and resolving conflicts

intermediate25–30 minHandbook pp. 41–42 Not started

Warm-up · from “Fast-forward and three-way merging”

When is a fast-forward possible?

No notes: write what you remember, then check. Recalling before reading is what makes it stick.

The problem

Two developers change the same line of a payment configuration. Git cannot infer which behavior the product requires. You must decide.

After this lesson you can

  • Read conflict markers.

  • Inspect all three Index stages.

  • Resolve and verify a merge safely.

Key terms

Full glossary

Say what each term means, then open it to check.

  • HEAD · from lesson 14

    Current symbolic branch reference or detached commit identity.

  • Index · from lesson 9

    Prepared path-to-object entries, plus metadata and conflict stages.

  • Commit · from lesson 7

    Object identifying a root tree, parent(s), metadata and message.

Visual mental model

  1. Stage 1base
  2. Stage 2 + 3ours + theirs
  3. Resolve
  4. Stage 0resolved

Build the mental model

During a normal unresolved content conflict on a file present in the base and both sides, the Index records stage 1 (base), stage 2 (ours), and stage 3 (theirs). Stage 0 is absent for that path. Some conflicts have missing stages, such as add/add conflicts with no base file. git ls-files -u exposes these entries, and git show :1:PATH, :2:PATH and :3:PATH display their contents.

SimulationBase, ours, theirs → your decision

A simplified model for building intuition. It does not read your sandbox; use the terminal for real behaviour.

Under the hood

The working file may have conflict markers separating ours and theirs. Resolve according to the intended behavior, not just by deleting markers. Stage the result, inspect the staged diff, run project tests, then complete the merge with git commit or git merge --continue. MERGE_HEAD identifies incoming parents. git merge --abort attempts to restore the pre-merge state; starting with clean work is safer.

Common mistake · important nuance

During an ordinary merge, ours means current HEAD and theirs means incoming. During rebase these roles often feel reversed. Do not choose a whole side without checking its meaning.

Move between parts freely. Completion counts only what you verify and answer.