How to deal with Git “Could not read” error

前端 未结 8 1150
萌比男神i
萌比男神i 2020-11-30 03:58

I am getting this error in my git repository:

22:09:15 $ git status
# On branch master
error: Could not read 8124cc15c63be92d534e4cdfa33c38d54deee122
error:          


        
8条回答
  •  时光取名叫无心
    2020-11-30 04:11

    I had a similar issue just now. The corruption arose when my laptop did a hard power-off during a git pull. I have a remote backup repository. First I had several object files in .git/objects/??/* that were zero size. After a cp -a backup of the repository, I did this:

    • remove the zero length objects
    • clone the remote repository into a ../fresh/ repository
    • in the broken repository, I did

      cat ../fresh/.git/objects/pack/pack-*.pack | git unpack-objects

    This filled up the missing objects in the object database. The repository seems to be back up now.

提交回复
热议问题