How does my git repository keep getting corrupted?

跟風遠走 提交于 2019-12-03 11:08:46
abligh

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!