EAD
git
corruption_error
ai_generated
partial
fatal: bad object HEAD
ID: git/bad-object
75%Fix Rate
80%Confidence
50Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 2 | active | — | — | — |
Root Cause
Git repository is corrupted. HEAD or objects are broken.
genericWorkarounds
-
90% success Try git fsck to identify corrupted objects
# Run filesystem check: git fsck --full # This will report: # broken link, missing blob/tree/commit, dangling objects # Fix missing objects by fetching from remote: git fetch origin
Sources: https://git-scm.com/docs/git-fsck
-
85% success Recover HEAD: git reflog to find last good commit, then git reset
git reflog git reset --hard <good-commit>
Sources: https://git-scm.com/docs/git-reflog
-
80% success If remote is intact, backup local branches then re-clone
# Backup current work: cp -r .git .git.bak git stash # if possible # Re-clone and restore branches: git clone <remote-url> fresh-clone cd fresh-clone # Copy any local-only branches from backup if needed
Sources: https://git-scm.com/book/en/v2/Git-Internals-Maintenance-and-Data-Recovery
Dead Ends
Common approaches that don't work:
-
Delete .git and re-clone
70% fail
Loses all local branches, stashes, and unpushed commits
-
Run git gc --aggressive
75% fail
gc can't fix corrupted objects — may make things worse
Error Chain
Frequently confused with: