Git Reference ยท Maintenance and Recovery
git verify-pack command
Reference for git verify-pack: validate packfile indexes, list every object with its size, offset and delta chain, and find the biggest objects in a repository.
git verify-pack validates packfiles. You give it the path of a pack's index (.idx) and it checks the pack against that index: the checksum of the pack, the ID of each object and the delta chains. With -v it also prints one line per object, which turns it into the standard tool to see what a pack really contains.
This is the command behind the well-known question "which files make my repository so big?": list every object with its packed size, sort by size, and map the biggest IDs back to file names.
git verify-pack -v .git/objects/pack/pack-<id>.idx
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 verify-pack [-v | --verbose] [-s | --stat-only] [--] <pack>.idx...
| Name | Description |
|---|---|
<pack>.idx |
One or more pack index files. The matching .pack must sit next to each one. |
-v, --verbose |
Print one line per object, then a summary of delta chain lengths. |
-s, --stat-only |
Print only the summary (object count per chain length), not the per-object lines. |
-- |
End of options, useful for unusual file names. |
Verbose line format: <object-id> <type> <size> <size-in-pack> <offset-in-pack> for a whole object, and <object-id> <type> <size> <size-in-pack> <offset-in-pack> <depth> <base-object-id> for a delta. For a whole object, size is the uncompressed size and size-in-pack is what it costs on disk. For a delta the size column describes the delta data, which is why a delta line shows tiny numbers, as in the first example.
Summary lines: non delta: N objects, chain length = 1: N objects, chain length = 2: ..., and finally <path>.pack: ok.
Returns: exit status 0 if every pack verifies; a non-zero status with an error message such as a checksum or index mismatch otherwise.
Usage notes
- Pass the
.idx, not the.pack. Passing a.packfile name also works in current Git (the extension is mapped), but the documented argument is the index. - Delta depth. A depth of 0 is a full object; larger numbers mean longer chains to reconstruct.
pack.depth(default 50) and--depthof git repack limit it. Long chains slow reads, short ones cost space. - Sorting by size.
sort -k3 -norders by the uncompressed size (third column) and-k4by packed size. Usegit rev-list --objects --allto map an ID to the path that was committed with it, as in the example. - Only packed objects. Loose objects are not listed. Run git repack or git gc first if a repository is mostly loose.
- Compared with fsck.
verify-packchecks only the packs you name. git fsck checks reachability and object content across the whole repository. - Receiving packs. Servers run the same checks automatically through
git index-pack --strictwhentransfer.fsckObjectsis on. - Output order. The listing is ordered by object ID, not by pack position; the offset column tells you where an object is stored.