Git Reference ยท Plumbing Commands
git index-pack command
Reference for git index-pack: create the .idx file for a packfile, read a pack from stdin, fix thin packs with --fix-thin and verify objects with --strict.
git index-pack reads a packfile, works out where every object starts, resolves deltas, checks the checksums, and writes the .idx file that lets Git find an object inside the pack quickly. A .pack without its .idx is unusable, so every fetch and clone ends with this step.
It has two main modes. Given a file name, it indexes a pack that is already on disk. With --stdin it reads a pack from a pipe, saves it into the repository's objects/pack directory and indexes it at the same time, which is what git fetch does with the data from the server.
git index-pack <file>.pack git index-pack --stdin [--fix-thin] [--keep] < incoming.pack
Try it
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Syntax
git index-pack [-v] [-o <index-file>] <pack-file> git index-pack --stdin [--fix-thin] [--keep[=<msg>]] [--strict] [--check-self-contained-and-connected] git index-pack --verify <pack-file>
| Name | Description |
|---|---|
<pack-file> |
The .pack to index. The index is written next to it with the extension .idx. |
-o <index-file> |
Write the index to this path instead. |
--stdin |
Read the pack from standard input and store it under objects/pack of the current repository. Prints pack<TAB><hash> (or keep<TAB><hash> with --keep). |
--fix-thin |
Complete a thin pack by appending the missing delta bases from the repository. Only valid with --stdin. |
--keep[=<msg>] |
Create a .keep file so git gc leaves the pack alone until the caller removes it. |
--strict |
Also check that every object is well formed and that links point to objects that exist. |
--verify |
Re-read an existing pack and index, and check the pack against them without writing. |
-v, --verify-stat |
Show progress or statistics. |
--object-format=<fmt> |
Hash algorithm of the pack when it cannot be detected (SHA-1 or SHA-256). |
--threads=<n> |
Threads used when resolving deltas. |
Output: without --stdin, the pack checksum (a 40-character hash for SHA-1 repositories) is printed.
Errors: a damaged pack (bad checksum, truncated data, wrong header) stops with fatal: ... and a nonzero status, and no index is written. A thin pack given without --fix-thin fails with an "unresolved deltas" message.
Usage notes
- File name. A pack named
pack-<hash>.packpairs withpack-<hash>.idx; the hash is the checksum printed byindex-packitself. Indexing a differently named file works but is unusual. - Thin packs only arrive through transport.
--fix-thinmakes them self-contained by adding the bases, so the stored pack is slightly larger than what you received. - Verification.
index-packchecks the checksum of every object, so--stdinis also an integrity check of data from the network. Settransfer.fsckObjectsto add the--strictchecks on fetch. - Small packs.
git fetchunpacks fewer thantransfer.unpackLimit(100 by default) objects into loose files with git unpack-objects instead of keeping a pack. - Not the same as
verify-pack.git verify-packinspects an existing index and prints the contents;index-packcreates it. - Reftable and multi-pack indexes are separate structures:
multi-pack-indexsits above many.idxfiles and does not replace them.