git-fsck-objects
Verify the connectivity and validity of objects
SYNOPSIS
git-fsck-objects [-v] [--unreachable] [--tags] [--full] [--strict]
PARAMETERS
-v, --verbose
Enable verbose mode, showing progress and details during scan.
--unreachable
Detect and report objects not reachable from any reference (potential orphans).
--tags
Verify tags reference valid commits, trees, blobs, or other tags (not refs).
--full
Scan all objects in repository, including loose unreachable ones (resource-intensive).
--strict
Treat dangling objects as errors, exiting non-zero instead of warning.
DESCRIPTION
git-fsck-objects is a low-level Git command for diagnosing repository health by scanning the object database (.git/objects). It checks SHA-1 checksums of every object, validates object formats, and verifies referential integrity—ensuring referenced objects exist and match expected checksums.
Starting from references (heads, tags, notes, etc.), it traverses the object graph. Missing objects cause 'broken link' errors; corrupt files trigger 'checksum mismatch' or 'invalid format' warnings.
It distinguishes dangling objects (valid but unreferenced, often harmless from ops like rebase) from unreachable ones (not traversable from refs). Options extend scanning: --full inspects all loose objects; --unreachable lists detached objects.
Ideal for detecting disk corruption, incomplete clones, or fs issues. Run periodically on servers. Non-zero exit on problems. Modern Git prefers git fsck [--full]; this is legacy but equivalent.
CAVEATS
Slow on large repos with --full; skips packed objects unless unpacked. Detects but does not fix issues—use git prune or git gc afterward. Run as repository owner to avoid permission errors.
EXIT STATUS
0: OK
1: warnings (dangling/unreachable)
128: fatal error (corruption, I/O fail).
TYPICAL OUTPUT
broken: missing <oid>
dangling blob <oid>
unreachable commit <oid>
checksum mismatch <oid>.
HISTORY
Created by Linus Torvalds in 2005 as git-fsck-objects for early Git (pre-1.5.4). Unified into git fsck by Junio C Hamano; --full replicates original behavior. Evolved with Git for better progress reporting, connectivity checks.


