How to deal with Git “Could not read” error

前端 未结 8 1151
萌比男神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:02

    I fixed this error by deleting the Capistrano 'repo' folder from my remote server directory. I went through a number of the other suggested problems and resolved that the problem didn't lie with my local project. The problem appeared to occur when Capistrano was executing pulling from the repo to the remote. For me, this was perhaps due to a halted deployment that left corrupted objects / object references. My host also had just done a server migration, perhaps something became corrupted during this process.

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2020-11-30 04:13

    i fixed the error by making changes in the same directory/project folder and then tried to commit the new change , what happened is i got an error msg 'invalid object 100644 e38e910ceb18b09f436f353c3a131bfe2caba130 for 'Book/alise_mathe/app/src/main/res/menu/drawermenu.xml' this msg solved the problem , i just refactored the drawermenu.xml by changing the file name to 'drawer_menu.xml'. added the changes committed pushed and thats all. (android-studio)

    I hope this helps some how

    0 讨论(0)
  • 2020-11-30 04:21

    If you don't have uncommited changes the easiest solution is to delete the local branch: git branch -D [branch name]

    and then checkout again the remote branch: git checkout -b [branch name] origin/[branch name]

    0 讨论(0)
  • 2020-11-30 04:21

    If none of the above steps work and you have local changes that you want to keep and have a remote repository in tact, this reset script works wonders.

    If in addition you need to keep your stash, copy the following files over manually:

    • .git/objects
    • .git/refs/stash
    • .git/logs/refs/stash
    0 讨论(0)
  • 2020-11-30 04:24

    On a "broken link" message, you could follow the GitFaq recommendations:

    • back up all your state so that anything you do is re-doable if you corrupt things more!
    • explode any corrupt pack-files
      • See "man git-unpack-objects", and in particular the "-r" flag.
        Also, please realize that it only unpacks objects that aren't already available, so you need to move the pack-file away from its normal location first (otherwise git-unpack-objects will find all objects that are in the pack-file in the pack-file itself, and not unpack anything at all)
    • replace any broken and/or missing objects
      • This is the challenging part.
        Sometimes (hopefully often!) you can find the missing objects in other copies of the repositories.
        At other times, you may need to try to find the data some other way (for example, maybe your checked-out copy contains the file content that when hashed will be the missing object?).
    • make sure everything is happy with "git fsck --full"
    • repack everything to get back to an efficient state again

    Notes:

    • missing objects can also be related to alternate (when you share objects between repositories) with git alternates (even though that can be risky).
    • The JGit/Egit eclipse plugin is also known to have a few issues.
      (Update February 2012: those plugins have come a long way and are now quite stable)

    Update July 2016 (7 years laters), with Git 2.10 soon to be released, you now have:

    git fsck --name-objects
    

    It helps naming the origin of those broken links

    See "How to fix git error broken link from tree to tree?" for more.

    0 讨论(0)
提交回复
热议问题