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.
fatal: pack has bad object at offset 1184237: inflate returned -3
error: packfile .git/objects/pack/pack-9fceb02.pack is corruptedCommon 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.
rm -rf repo
git clone https://github.com/org/repo.git repoRemove the bad pack and refetch
If re-cloning is expensive, drop the corrupt pack and let Git refetch the objects.
git fsck --full # identify the bad pack
rm .git/objects/pack/pack-9fceb02.{pack,idx}
git fetch -p origin
git fsck --fullHow to prevent it
- Avoid caching
.git; corruption travels with the cache. - Use shallow clones and ephemeral runners to keep stores fresh.
- Run
git fsckin long-lived self-hosted checkouts to catch corruption early.