Reverse of pack-objects.
git unpack-objects reads a packfile from stdin and writes every contained object back out as a loose object under .git/objects/xx/. It is the literal inverse of pack-objects and is mostly a forensics tool when a pack or its index is suspect.
Pack in, loose objects out. The command does not touch refs, the index, or the working tree; it only materialises blobs, trees, commits, and tags as individual files in the object store.
git unpack-objects [-n] [-q] [-r] [--strict] < pack-*.pack
# Note: pack is read from stdin, not given as an argument.
# The matching .idx file is NOT used; the pack is decoded directly.| Flag | What it does |
|---|---|
-n, --dry-run | Parse the pack and report what would be unpacked; write nothing. |
-q, --quiet | Suppress the progress meter. |
-r | Recovery mode: keep going past broken/duplicate objects instead of aborting. |
--strict | Run fsck-style checks on each object as it is written. |
--max-input-size=<n> | Refuse packs larger than n bytes; useful when scripting against untrusted input. |
git unpack-objects -n --strict < /tmp/suspect.packgit unpack-objects -r < .git/objects/pack/pack-abc123.packcat pack-abc123.pack | git unpack-objects -qgit unpack-objects --strict < incoming.packHit each option, then Check answers. Score is recorded; Next is always open.