https://stackoverflow.com/questions/11706215/how-to-fix-git-error-object-file-is-empty
Error:error: object file .git/objects/31/65329bb680e30595f242b7c4d8406ca63eeab0 is empty
fatal: loose object 3165329bb680e30595f242b7c4d8406ca63eeab0 (stored in .git/objects/31/65329bb680e30595f242b7c4d8406ca63eeab0) is corrupt
Fix:The git object files have gone corrupt (as pointed out in other answers as well). This can happen during machine crashes, etc.
I had the same thing. After reading the other top answers here I found the quickest way to fix the broken git repository with the following commands (execute in the git working directory that contains the .git folder):
(Be sure to back up your git repository folder first!)
find .git/objects/ -type f -empty | xargs rm
git fetch -p
git fsck --full
This will first remove any empty object files that cause corruption of the repository as a whole, and then fetch down the missing objects (as well as latest changes) from the remote repository, and then do a full object store check. Which, at this point, should succeed without any errors (there may be still some warnings though!)
PS. This answer suggests you have a remote copy of your git repository somewhere (e.g. on GitHub) and the broken repository is the local repository that is tied to the remote repository which is still in tact. If that is not the case, then do not attempt to fix it the way I recommend.
No comments:
Post a Comment