Theory
Theory: fsck Walks the Graph; Repair is Restore Reachability
Corruption is missing or malformed objects. Dangling objects are normal (amended commits). Repair means getting a reachable graph again — often from another clone.
Invariants
git fsckreports missing, unreachable, and malformed objects.- Another clone of the same DAG is the best object source.
- Reflog may still name “lost” commits locally.
- Do not
rm -rf .gituntil you have a copy of objects you need.
tip → commit → tree → blob all hashes must exist
missing blob = unreadable file at that path in that commit
What can break
- Running random
rmin.git/objects. - Assuming
fsckdangling = disaster.
How to read this chapter
fsck, error patterns, procedures, corruption lab.