# git pack-objects: Usage, Options & Common CI Errors

> git pack-objects bundles objects into a compressed packfile. Reference for --stdout, --revs, --all, and the memory and corruption errors seen in CI.

Source: https://latchkey.dev/learn/command-reference/git-pack-objects  
Updated: 2026-06-25

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

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

## 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
```

> `git rev-parse --abbrev-ref HEAD` returns the literal string `HEAD` on a detached checkout rather than a branch name. On GitHub Actions read `github.ref_name` instead; the git command cannot know what it was checked out for.

## FAQ

### 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.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
