Git Index Entries and Conflict Stages
Index entries are not only filenames
The index records a proposed snapshot using path, mode, object ID and stage, plus implementation metadata. A normal resolved entry is stage 0. A content conflict can replace it with stages 1 (merge base), 2 (ours) and 3 (theirs). Not every conflict has all three: an add/add conflict has no base file. The working file with conflict markers is separate from these indexed blobs.
Inspect before resolving
Pause at the conflict in the manual lab, where base says Water every 3, main says Water every 2 and topic says Water every 3 days. In this ordinary merge, stage 2 is main and stage 3 is topic. Do not generalize these labels to rebase: its sides have different roles.
git ls-files --stage -- notes.txtgit show :1:notes.txtgit show :2:notes.txtgit show :3:notes.txtResolve the intended behavior
The requirement is to keep the two-day interval and add its unit. Edit only the fixture-owned notes.txt, then stage the resolution. git add replaces unmerged stages for this path with a stage-0 entry; it does not finish the merge commit by itself. Inspect unmerged entries before committing.
printf "Water every 2 days\n" > notes.txtgit add -- notes.txtgit ls-files --stage -- notes.txtgit ls-files -ugit diff --cachedPractice and check
Before staging, predict that write-tree refuses an unmerged index. After staging, expect one stage-0 record and no unmerged entries. write-tree may create a tree object; it is not a read-only command. Complete the merge only after checking all paths and the intended content.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Git Index Entries and Conflict Stages — knowledge check
Reason about Git objects, index and reference state.
Which stage denotes a resolved index entry?
Which stage denotes the base in an ordinary three-way conflict?
Which stage denotes the incoming side of an ordinary merge?
After staging a resolved file, what happens to its conflict stages?
What does write-tree do with an unresolved index?