Skip to content
Latchkey

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

Terminal
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.pack

Options

FlagWhat it does
--stdoutWrite the pack to standard output
--revsRead commits and pack reachable objects
--allPack 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.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →