Skip to content
Latchkey

git fsck: Usage, Options & Common CI Errors

git fsck checks your repository for corruption and reports dangling or unreachable objects.

fsck is the integrity checker. It also surfaces dangling commits you might recover after a destructive operation.

What it does

git fsck (file-system check) verifies the connectivity and validity of objects in the database, reporting missing, corrupt, dangling, and unreachable objects.

Common usage

Terminal
git fsck
git fsck --full
git fsck --lost-found             # write dangling objects to disk
git fsck --unreachable

Options

FlagWhat it does
--fullCheck all object packs and alternates
--lost-foundWrite dangling blobs/commits to .git/lost-found
--unreachablePrint objects not reachable from any ref
--no-danglingSuppress dangling-object reports

Common errors in CI

error: object file … is empty or "fatal: loose object … is corrupt" indicates real repository corruption - usually a truncated write or disk issue on the runner. The reliable CI fix is a fresh clone; fsck plus dangling-object recovery is for local rescue, not pipelines.

Related guides

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