使用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远程梅干起源,但没用。


当前回答

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

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

其他回答

尝试了这些,但没有对我起作用:

$ git gc --prune=now
$ git remote prune origin
$ git fetch --prune

我不得不通过删除本地文件夹并再次克隆来解决这个问题。

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

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

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

这对我来说很有用:

git gc --prune=now

写下可能导致此问题的具体案例。

有一天,我推送了一个名为“feature/subfeature”的分支,同时在远程拥有“feature”分支。

该操作在我这边运行良好,没有任何错误,但当我的同事提取和/或提取任何分支时,他们都收到了完全相同的错误消息:无法更新本地ref,无法锁定ref的refs/remotes/origin/feature/subfeature。

这是通过删除remote上的功能分支(git push--delete origin功能),然后在我同事的repo上运行git remote prune origin来解决的,这会生成包含*[pruned]origin/feature的消息。

所以,我猜git fetch试图在git内部(.git/…)的功能文件夹中创建子功能引用,但创建文件夹失败,因为已经有了功能引用。

我也遇到了。在我的情况下,糟糕的裁判是大师,我做了以下事情:

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

这使得git恢复了ref文件。在那之后,一切又如愿以偿了。