Diagnosing corruption
Repositories corrupt through power loss, disk failure, partial network sync, or buggy non-Git tools touching .git. Symptoms range from "fatal: bad object" to wrong content silently delivered. Diagnosis starts with fsck:
git fsck --full
git fsck --full --strict --no-dangling
git fsck --connectivity-only
git fsck --lost-found
--lost-found writes orphaned objects to .git/lost-found/ for manual inspection.