Git Reference ยท Plumbing Commands
git unpack-objects command
Reference for git unpack-objects: read a packfile from standard input and write its objects as loose files, with -n, -q, --strict and size-limit notes.
git unpack-objects is the reverse of packing. It reads a packfile from standard input and writes every object in it as an individual loose file under .git/objects/xx/. It does not keep the pack, and it does not need an index.
Git uses it when a small amount of data arrives over the network: it is cheaper to unpack a handful of objects than to store a tiny pack. You can use it directly to import a pack produced by git pack-objects --stdout, or to see what a pack really contains.
git unpack-objects [-n] [-q] [--strict] < file.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 unpack-objects [-n] [-q] [-r] [--strict] [--max-input-size=<size>] < <pack-file>
| Name | Description |
|---|---|
-n |
Dry run. Check the pack but write nothing. |
-q |
Quiet: no progress output. |
-r |
Recover: try to unpack as much as possible from a damaged pack instead of stopping at the first error. |
--strict |
Check each object for validity and that its links lead to objects that exist or are in the same pack. Objects that fail are not written. |
--max-input-size=<size> |
Refuse a pack larger than this size. |
--pack_header=<version>,<count> |
Used internally when the pack header was already consumed by the caller. |
Input: the pack must be on standard input; the command never reads a file by name. Nothing is printed on success.
Errors: a bad pack signature, a checksum mismatch or a truncated stream ends with fatal: and a nonzero status. Objects unpacked before the failure remain on disk.
Usage notes
- Existing objects are skipped. Running the command twice with the same pack changes nothing the second time, because Git does not rewrite objects that already exist (loose or in a pack).
- Deltas are resolved. A pack stores many objects as deltas; the loose files contain the full, zlib-compressed objects, so unpacking can use much more disk space than the pack did. A repository of 1 MB packed may need many megabytes loose.
- Standard input only. The command reads a pack stream, not a file name or a directory. To expand a pack that already lives in a repository, copy the
.packfile out and feed it to a different, empty repository; in the original repository Git would skip every object it already has. - Thin packs fail when the missing delta bases are not in the repository. Use git index-pack with
--fix-thinfor those. - Transfer limit.
git fetchandgit receive-packcallunpack-objectswhen a pack holds fewer thantransfer.unpackLimitobjects (default 100, orfetch.unpackLimit/receive.unpackLimit) andindex-packfor larger ones. - Many loose files are slow. Run
git gcorgit repackafterwards if you unpacked a lot.