Interview Prep/Git & GitHub/Lost Work, HEAD and History Problems

`error: unable to read sha1 file of src/app.js (3b18e5...)` or `error: inflate: data stream error`

AdvancedTroubleshootingLost Work, HEAD and History Problems
Answer

Likely causes → A loose object or pack is corrupt (disk error, bad memory, interrupted write, sync tool).

Diagnose →

git fsck --full --strict
git count-objects -v

Fix → Move the corrupt object away (mv .git/objects/3b/18e5... /tmp/), run git fetch origin (pulls missing objects from remote), then git fsck again. For a bad pack, run git unpack-objects on salvageable parts or re-clone and copy over unpushed branches via git format-patch or git bundle. Also test the disk and RAM.

Prevent → Use reliable storage, and do not interrupt git gc or repack.

All Git & GitHub questions Roadmap: Git & GitHub

More on Lost Work, HEAD and History Problems