When the local git repository is corrupted, the following message will be thrown by git for all type of git commands.
error:
object file .git/objects/34/a933ab83249282f901d07ff29eb5346f1cd6ca is empty
error:
object file .git/objects/34/a933ab83249282f901d07ff29eb5346f1cd6ca is empty
fatal:
loose object 34a933ab83249282f901d07ff29eb5346f1cd6ca (stored in
.git/objects/34/a933ab83249282f901d07ff29eb5346f1cd6ca) is corrupt
This
can be appeared after a computer crash/ forceful shutdown or even after a
improper shutdown of the development IDE such as jIdea or Eclipse (If git is
integrated and used on them).
This
can be even non recoverable depending on the damage happened to the Git
metadata entries.
Method 1
You
can check the status of the object by following command,
$>
git fsck --full
broken
link from tree
89b563c6d23595e7cb2a21e5ebbb53655278dff8
to
blob xx852147
missing
blob xx852147
The
object with broken link will be listed if any.
Then
it is possible to check the file on which the empty object is a hash of.
$>
git ls-tree 89b56
...
...
12264
blob xx852147 <file_name>
Then
the hash should be created using the relevant file name
$>
git hash-object -w <file_path><file_name>
This
will fix the issue by recalculating the hash and updating the Git metadata set.
Method 2
In
unrecoverable scenarios any of these won't work, then the basic steps has to be
used instead.
- Back up the git folder
- Clone the repository again
- patch the changes from the back up file by file to the fresh copy.
No comments:
Post a Comment