Warm-up · from “Fast-forward and three-way merging”
When is a fast-forward possible?
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 glossarySay 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
- Stage 1base
- Stage 2 + 3ours + theirs
- Resolve
- 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.
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.