我的git储存库如何不断损坏? [英] How does my git repository keep getting corrupted?

查看:78
本文介绍了我的git储存库如何不断损坏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ubuntu 14.10(64位),git版本2.1.0.这是一个已经存在数年的存储库,并且最近开始出现问题.

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.

有时,我将更改分支,编辑文件并键入git status.它将显示一堆实际上完全没有更改的已修改"文件.

Sometimes I'll change branches, edit a file, and type git status. It will show a bunch of files as "modified" that actually haven't changed at all.

如果我输入以下内容:

$ git commit -am "fixed sms message"

我收到这样的错误:

error: short read No such file or directory
error: globalstatic/images/console/avatar_f.gif: failed to insert intodatabase
error: unable to index file globalstatic/images/console/avatar_f.gif
fatal: updating files failed

如果除了按向上箭头键然后再次按Enter以外,我什么也没做,那么我会得到关于git status中出现的下一个文件的错误,该文件从未真正更改过.我可以这样做,直到我用尽了git status中未更改的文件列表,然后它将正确提交.

If I do nothing other than press the up arrow key and press enter again, I'll get an error about the next file that showed up in git status that never actually changed. I can do this until I've exhausted the list of files in git status that didn't change, and then it will commit correctly.

git fsck --full确实报告发现了问题,但实际上没有解决任何问题.我只需要继续尝试提交,直到它起作用为止.这是git fsck --full给我带来问题时的输出:

git fsck --full does report that it has found problems, but doesn't actually fix anything. I just have to keep trying to commit until it works. Here's output of git fsck --full when it's giving me issues:

Checking object directories: 100% (256/256), done.
Checking objects: 100% (120625/120625), done.
dangling tag c7539416829fb0748bc32dda3beb386bac46ea9a
dangling blob 88a0700db2a75e6ea2b14b9a5af15ece63a80805
dangling blob f4c664b0044f3d5efff1148717dc68b940e08574
dangling blob 1bf6185091177fd5a496f5bf031f4d666fec92da
dangling commit fee4bdcc078789a3745aa1311f128a6b61a81736
dangling blob 9f14e68da29d49895b1ea303ed33cb390fc56b76
dangling blob 784a02e974b81f35952fb7c31bf2dcb1a7bfeda8
dangling blob 9e92d6cf395206152123f9a29edb95652114fd34
dangling commit 1294f626dcb76cafa560f65792517655fb8a52ae
dangling blob bceb1adde285e71109723211a1bcb5b0fa126681
dangling tag 19f4be8e7b53465b13359bc4350b5e87c5942560
dangling blob 93f96a3b5e995032a50723af796dab9ae36fb974
dangling blob a25bdfab82fef920935478ee2cefe4dc2e81bbf6
dangling blob af7187350341f3d7795d35cc1f0cee78eb9f9fdf
dangling blob e2a1db9e3d3d438c8b03cb6254ca492e505be6f8

如果我多次运行它,则会收到相同的消息.没有什么变化.

If I run it more than once, I get the same message. Nothing changes.

这是怎么回事?

推荐答案

不知道发生了什么(除了显而易见的是,某些东西正在破坏您的git repo),但是我知道我该如何解决类似的问题-我正在希望那是一个隐含的问题!

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!

  • 将您的存储库推送到某个地方(可以使用本地裸仓库)
  • 将旧存储库重命名为myrepo.broken或类似名称
  • 签出您推送到先前位置的回购的新副本
  • 确定没有丢失任何内容后,删除旧存储库
  • 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):

  • 请注意,悬空的斑点和提交可能完全没有问题-参见例如此处.短读的东西应该发生.
  • git gc --prune=now会修剪掉所有悬空的blob和提交.
  • 此处'sa维护和数据恢复教程.
  • 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服务器处于躲避状态时,NFS挂载的包含git树的主目录
  • 不区分大小写的归档系统
  • 断电/系统崩溃导致FS损坏,或在提交过程中途发生
  • 系统中未识别的gremlins

避免重复其中的第一和第二很容易,第三是可以理解的,但是第四往往很棘手.避免在午夜之后进食.

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.

这篇关于我的git储存库如何不断损坏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆