Skip to content
Latchkey

Git "fatal: pack has bad object" in CI

A packfile in the local repository is corrupt - Git found a bad object inside it. The packed data was damaged in transit or on disk, so operations that read it fail.

What this error means

Git fails with fatal: pack has bad object at offset <n> or error: packfile .git/objects/pack/pack-... is corrupted. It commonly follows a truncated fetch or a restored cache with an incomplete pack.

git output
fatal: pack has bad object at offset 1184237: inflate returned -3
error: packfile .git/objects/pack/pack-9fceb02.pack is corrupted

Common causes

A truncated or corrupted pack transfer

A fetch/clone that was cut short can write an incomplete packfile, so a later read finds a bad object inside it.

A restored cache containing a partial pack

Caching .git (or the objects directory) can restore a packfile that was only partially written, corrupting the store for the next job.

How to fix it

Re-clone into a clean workspace

Discarding the corrupt store and cloning fresh is the most dependable CI fix.

Terminal
rm -rf repo
git clone https://github.com/org/repo.git repo

Remove the bad pack and refetch

If re-cloning is expensive, drop the corrupt pack and let Git refetch the objects.

Terminal
git fsck --full        # identify the bad pack
rm .git/objects/pack/pack-9fceb02.{pack,idx}
git fetch -p origin
git fsck --full

How to prevent it

  • Avoid caching .git; corruption travels with the cache.
  • Use shallow clones and ephemeral runners to keep stores fresh.
  • Run git fsck in long-lived self-hosted checkouts to catch corruption early.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →