How does my git repository keep getting corrupted?

前端 未结 1 1780
無奈伤痛
無奈伤痛 2021-02-13 21:09

I am using ubuntu 14.10 (64bit), git version 2.1.0. This is a repository that has been around for several years, and has recently started having issues.

Sometimes I\'ll

相关标签:
1条回答
  • 2021-02-13 22:00

    No idea what's going on (beyond noting the obvious, that something is corrupting your git repo), but I know how I fix things like this - I'm hoping that was an implicit question!

    • push your repo somewhere (a local bare repository will be fine)
    • rename your old repository to myrepo.broken or similar
    • check out a fresh copy of the repo you pushed to the previous place
    • Once you are sure you have lost nothing, delete the old repo

    I far prefer the above method to futzing with the repo itself. But if you insist (and I'd make a backup first):

    • Note the dangling blobs and commits may well be no problem at all - see e.g. here. The short read thing should not happen.
    • git gc --prune=now will prune all your dangling blobs and commits.
    • Here's a tutorial on maintenance and data recovery.

    As far as what's going on is concerned, I've had problems with

    • NFS mounted home directories containing git trees when the NFS server is dodgy
    • case insensitive filing systems
    • power loss / system crash causing FS corruption, or happening half way through commit
    • unidentified gremlins in the system

    It's easy enough to avoid the first and second of these repeating, and the third is understandable, but the fourth tends to be tricky. Avoid feeding after midnight.

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