What can I do with Git corruption due to a missing object?

前端 未结 3 1688
梦毁少年i
梦毁少年i 2021-01-04 12:05

I just went to clone a repository on another remote server and ran into an issue trying to do so:

git clone git@codebasehq.com:blah/blah/docs.git
Cloning int         


        
3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-04 12:22

    Simple push will not fix this problem, because git sees it has the commit that refers to the corrupt file and will assume it has all the objects it needs.

    Do you have another repository with the project that does not report any problems with fsck (and has the file in question)? E.g. on your local machine? Than you should try:

    1. Put the corrupt repository aside.
    2. Clone the good repository in it's place.
    3. Push any branches the old repository had from other repositories or the old repository.

    Since this kind of error means the file on disk was corrupt, I suggest you do a thorough check of the filesystem, the disk and also memory (the data could get corrupted in memory when git was saving them).

    Note: While all disks have at least some checksums, most memory chips have none at all, so a memory fault is more likely to go undetected than a disk fault. memtest86+ is a good way to check memory.

提交回复
热议问题