Progress:
TIER 2 · MODULE 19· Intermediate

git fsck

Find dangling and broken objects.

🎯 What & why

git fsck (file system check) verifies the integrity of the object database: hashes match, refs point to real objects, no corruption. Run it when something feels wrong, or proactively on critical repos.

🧠 Mental model

Think fsck for your .git directory. It walks every object, every ref, every reflog entry and reports anything that does not add up - dangling, unreachable, broken, missing.

🛠️ Synopsis

git fsck [--tags] [--root] [--unreachable] [--cache] [--no-reflogs]
              [--full] [--strict] [--verbose] [--lost-found]
              [--connectivity-only] [--name-objects] [<object>...]

🎚️ Switches & options

FlagWhat it does
--fullCheck all object directories including alternates (default in modern Git)
--strictStricter checks - flags trees with bad permissions, etc.
--unreachableReport objects not reachable from any ref or reflog
--danglingReport objects no other object refers to (default: on)
--lost-foundWrite dangling objects into .git/lost-found/ for recovery
--no-reflogsTreat reflogs as not a source of reachability
--connectivity-onlySkip hash verification - faster, only checks the graph

💡 Use cases

🧪 Examples

Standard check
git fsck
Aggressive check
git fsck --full --strict
Recover lost commits
git fsck --lost-found
Fast graph-only check
git fsck --connectivity-only

🎓 Recommendations

🪤 Common pitfalls

🔗 Related modules

📝 Quiz

Hit each option, then Check answers. Score is recorded; Next is always open.