Skip to content
LatchkeyLatchkey home

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.

Using this in CI

CI checkouts are shallow and detached by default, which changes the answer this command gives you. Commands that read history, branch names, or tags need the checkout configured for it.

.github/workflows/ci.yml
- uses: actions/checkout@v4
  with:
    fetch-depth: 0   # history, tags, and git describe all need this

- run: |
    git rev-parse --is-shallow-repository   # expect false
    git rev-parse --abbrev-ref HEAD          # prints HEAD when detached

Frequently asked questions

git pack-objects: Usage, Options & Common CI Errors?
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 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

References

Run this faster and cheaper on Latchkey managed runners - self-healing included. Start free → 30-day trial · No credit card