git pack-objects: Usage, Options & Common CI Errors
git pack-objects compresses a set of Git objects into an efficient packfile.
Packing is what makes fetch, push, and storage efficient. You rarely call pack-objects directly, but understanding it explains repack behavior and the memory errors big repos hit in CI.
What it does
git pack-objects takes a list of object ids and writes a single delta-compressed packfile (plus an index), reusing existing deltas where possible to minimize size.
Common usage
git pack-objects --revs --stdout < object-list > out.pack
git rev-list --objects --all | git pack-objects pack-prefix
git pack-objects --all --stdout > everything.packOptions
| Flag | What it does |
|---|---|
| --stdout | Write the pack to standard output |
| --revs | Read commits and pack reachable objects |
| --all | Pack objects from all refs |
| --window=<n> / --depth=<n> | Tune delta search |
| --threads=<n> | Parallel delta compression |
Common errors in CI
fatal: Out of memory, malloc failed during delta compression on large repos - lower pack.windowMemory / pack.deltaCacheSize, or reduce --window and --threads on memory-limited runners. "fatal: packfile is corrupted" points at a truncated artifact or a disk that filled mid-write.