Progress:
TIER 3 · MODULE 06· Expert

git index-pack

Turns received pack into a usable indexed pack.

🎯 What & why

git index-pack builds the .idx sidecar file for a .pack so Git can random-access objects in it. Without an index, a packfile is just an opaque blob.

🧠 Mental model

fetch/clone receive a pack stream from the remote and hand it to index-pack to verify, resolve deltas, and emit pack-XXXX.idx. It is the receiving end of the wire protocol.

🛠️ Synopsis

git index-pack [-v] [-o <index>] [--keep[=<msg>]] [--threads=<n>] <pack>
git index-pack --stdin [--fix-thin] [--keep] [-o <index>] [<pack>]
git index-pack --check-self-contained-and-connected ...

🎚️ Switches & options

FlagWhat it does
-o <index>Write the index to <index> instead of pack-<sha>.idx alongside the pack.
--index-version=<n>[,<offset>]Pick idx format version (1 or 2); v2 is the modern default.
-v / --verify-statVerbose progress / verify a pack and print stats.
--keep[=<msg>]Create a .keep file so repack/gc won't merge/delete the pack.
--fix-thinAppend base objects so a 'thin' pack from the network becomes self-contained.
--check-self-contained-and-connectedConfirm pack stands alone and connects to existing history.
--stdinRead the packfile from stdin (used by fetch/receive-pack).
--threads=<n>Parallelize delta resolution; defaults to pack.threads.

💡 Use cases

🧪 Examples

Index an existing pack
git index-pack -v .git/objects/pack/pack-abc123.pack
Index from stdin (like fetch does)
cat incoming.pack | git index-pack --stdin --fix-thin -o incoming.idx
Verify and stat a pack
git index-pack --verify-stat .git/objects/pack/pack-abc123.pack
Mark pack as keep
git index-pack --keep=mirror-2026-05 mirror.pack

🎓 Recommendations

🪤 Common pitfalls

🔗 Related modules

📝 Quiz

Hit each option, then Check answers. Score is recorded; Next is always open.