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 --unreachableOptions
| Flag | What it does |
|---|---|
| --full | Check all object packs and alternates |
| --lost-found | Write dangling blobs/commits to .git/lost-found |
| --unreachable | Print objects not reachable from any ref |
| --no-dangling | Suppress 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
git gc: Usage, Options & Common CI Errorsgit gc compresses and prunes the object database to keep the repo fast and small. Reference for --aggressive,…
git reflog: Usage, Options & Common CI Errorsgit reflog records where HEAD and branches have been, so you can recover lost commits. Reference for show, ex…
git reset: Usage, Options & Common CI Errorsgit reset moves HEAD and optionally the index and working tree. Reference for --soft, --mixed, --hard, and ho…
git cat-file: Usage, Options & Common CI Errorsgit cat-file inspects Git objects - their type, size, and content. Reference for -t, -s, -p, --batch, and the…