Progress:
TIER 3 · MODULE 17· Expert

git unpack-objects

Reverse of pack-objects.

🎯 What & why

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.

🧠 Mental model

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.

🛠️ Synopsis

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.

🎚️ Switches & options

FlagWhat it does
-n, --dry-runParse the pack and report what would be unpacked; write nothing.
-q, --quietSuppress the progress meter.
-rRecovery mode: keep going past broken/duplicate objects instead of aborting.
--strictRun 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.

💡 Use cases

🧪 Examples

Dry-run a suspect pack
git unpack-objects -n --strict < /tmp/suspect.pack
Recover what you can from a broken pack
git unpack-objects -r < .git/objects/pack/pack-abc123.pack
Explode a pack into loose objects
cat pack-abc123.pack | git unpack-objects -q
Audit objects with strict fsck checks
git unpack-objects --strict < incoming.pack

🎓 Recommendations

🪤 Common pitfalls

🔗 Related modules

📝 Quiz

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