Turns received pack into a usable indexed pack.
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.
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.
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 ...| Flag | What 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-stat | Verbose progress / verify a pack and print stats. |
--keep[=<msg>] | Create a .keep file so repack/gc won't merge/delete the pack. |
--fix-thin | Append base objects so a 'thin' pack from the network becomes self-contained. |
--check-self-contained-and-connected | Confirm pack stands alone and connects to existing history. |
--stdin | Read the packfile from stdin (used by fetch/receive-pack). |
--threads=<n> | Parallelize delta resolution; defaults to pack.threads. |
git gc consolidation.git index-pack -v .git/objects/pack/pack-abc123.packcat incoming.pack | git index-pack --stdin --fix-thin -o incoming.idxgit index-pack --verify-stat .git/objects/pack/pack-abc123.packgit index-pack --keep=mirror-2026-05 mirror.pack--stdin with --fix-thin when ingesting from a remote; thin packs need bases.git verify-pack -v afterwards to spot-check the resulting .idx.Hit each option, then Check answers. Score is recorded; Next is always open.