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

Also available as: JSON · Markdown
78%Fix Rate
82%Confidence
50Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
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.

generic

Workarounds

  1. 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.
  2. 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:

  1. 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.

  2. 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

Leads to:
Preceded by:
Frequently confused with: