git
corruption
ai_generated
true
error: object file .git/objects/ab/cdef1234 is empty; error: unable to read sha1 file of file.txt
ID: git/object-corrupted
78%Fix Rate
82%Confidence
50Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 2 | active | — | — | — |
Root Cause
A git object file is empty, truncated, or contains invalid data. Typically caused by disk corruption, power loss during write, filesystem bugs, or aggressive antivirus software modifying files in .git/objects.
genericWorkarounds
-
85% success Fetch the missing/corrupted object from the remote
Remove the empty/corrupt object file: rm .git/objects/ab/cdef1234. Then git fetch origin to re-download the object from the remote. Verify with git fsck.
-
95% success Re-clone the repository preserving local branches
Export local-only work: git format-patch origin/main..my-branch. Clone fresh: git clone <url> fresh-repo. Apply patches: git am *.patch in the fresh clone.
Dead Ends
Common approaches that don't work:
-
Deleting the corrupted object file manually
75% fail
Removing the object breaks any references to it; git cannot reconstruct the object without additional information. This can make the corruption worse.
-
Running git gc to fix the corrupted object
85% fail
gc cannot repair corrupted objects; it may fail entirely when it encounters the corrupt data during repacking
Error Chain
Frequently confused with: