Theory

Updated

October 30, 2026

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

  1. git fsck reports missing, unreachable, and malformed objects.
  2. Another clone of the same DAG is the best object source.
  3. Reflog may still name “lost” commits locally.
  4. Do not rm -rf .git until 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 rm in .git/objects.
  • Assuming fsck dangling = disaster.

How to read this chapter

fsck, error patterns, procedures, corruption lab.