.git/index (also called the staging area or cache) is a binary file holding the snapshot of what your next commit will look like.
Format: a sorted list of entries, one per tracked file, containing:
- File path
- Mode (100644, 100755, 120000)
- Blob hash (the content you've staged)
- Stat info (mtime, size) — used for fast change detection
- Stage number — 0 normally; 1/2/3 during merge conflicts (base/ours/theirs)
Inspect:
git ls-files --stage # human-readable index
git ls-files --stage | head # first few entries
When you git add, Git updates this file. When you git commit, Git creates a tree object from the index and a commit pointing at it.
Conflict state: during a merge, conflicted files have entries with stage numbers 1/2/3. git add collapses them back to stage 0, signaling resolution.