如果 git fetch
因为 Ctrl-C 或者连接问题等原因被中断,之后执行 git fetch
或者 git pull
命令会失败。
If git fetch
is interrupted, for example by Ctrl-C or connectivity problems, then executing git fetch
or git pull
commands will fail.
user@computer:~/code/openttd-git$ git fetch
^C
user@computer:~/code/openttd-git$ git fetch
error: Unable to find 22d90742fc79a9011fb86ee03d8aeea66bc12657 under http://git.openttd.org/openttd/trunk.git
Cannot obtain needed object 22d90742fc79a9011fb86ee03d8aeea66bc12657
error: Fetch failed.
我认为这与代码库无关。使用git clone
将此破损的本地代码库复制到新的本地代码库中并不能解决问题。到目前为止,我知道的唯一解决方案是将整个远程代码库(origin/master
)克隆到新的本地代码库中。但是是否有更好(更快)的解决方案呢?有一个Debian bug报告,最后一条消息是在2011年2月发布的。这是我遇到的同样的错误吗?还是已经有修复或任何解决方案或解决方法了?我的git版本是1.7.10。
$ git fsck
输出:Checking object directories: 100% (256/256), done.
Checking objects: 100% (161159/161159), done.
然后$ git gc
输出:Counting objects: 157646, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (24579/24579), done.
Writing objects: 100% (157646/157646), done.
Total 157646 (delta 133211), reused 157173 (delta 132738)
。然后$ git fetch
输出与上述相同,所以这并没有解决问题。 - nrz