使用git 1.6.4.2时,当我尝试git pull时,会出现以下错误:

error: unable to resolve reference refs/remotes/origin/LT558-optimize-sql: No such file or directory
From git+ssh://remoteserver/~/misk5
 ! [new branch]      LT558-optimize-sql -> origin/LT558-optimize-sql  (unable to update local ref)
error: unable to resolve reference refs/remotes/origin/split-css: No such file or directory
 ! [new branch]      split-css  -> origin/split-css  (unable to update local ref)

我尝试过git远程梅干起源,但没用。


当前回答

我在使用SourceTree时遇到了这个问题。我试着再拉一次,结果成功了。我想我切换分行(结账)太快了。

我的情况与海报有点不同,因为我的存储库相对合作,没有任何明显的腐败。

其他回答

解释:您的远程repo(在GitHub/BitBucket中)分支似乎已被删除,尽管您的本地引用未被更新并指向不存在的引用。

为了解决这个问题:

git fetch --prune
git fetch --all
git pull

额外阅读-参考Git文档:

gitfetch-从另一个存储库下载对象和引用--全部取下所有遥控器。--修剪提取后,删除远程上不再存在的任何远程跟踪分支。

$ rm .git/refs/remotes/origin/master

$ git fetch

来自bitbucket.org:xx/mkyong教程

df0eee8..3f7af90  master     -> origin/master

$ git pull

已经是最新的。

我只是想补充一下Git引用损坏的可能原因之一。

可能的根本原因

在我的系统(Windows 7 64位)上,当BSOD发生时,一些存储的参考文件(最有可能是BSOD发生后当前打开/写入的)会被NULL字符(ASCII 0)覆盖。

正如其他人提到的,要修复它,只需删除那些无效的引用文件并重新获取或重新提取存储库就足够了。

实例

错误消息:

无法锁定引用“refs/remotes/origin/some/branch”:无法解析引用“refs/remotes/origin/some/bbranch”:引用已断开

解决方案:

删除存储在文件%repo_root%/.git/refs/remotes/origin/some/branch中的引用refs/remotes/corigin/sme/branch。

我也遇到过同样的问题,并通过查找出错的文件来解决:

\repo\.git\refs\remotes\origin\master

这个文件充满了null,我用github的最新引用替换了它。

从项目中手动删除特定分支的文件

.git/refs/remotes/origin/master
 git gc --prune=now
 git pull