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


当前回答

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

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

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

其他回答

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

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

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

在尝试从git捆绑包创建的文件中克隆时遇到此问题,其他答案都无效,因为我无法克隆repo(因此git gc和删除/编辑文件是不可能的)。

然而,还有另一种方法可以解决这个问题-.bundle文件的源文件以以下开头:

# v2 git bundle
9a3184e2f983ba13cc7f40a820df8dd8cf20b54d HEAD
9a3184e2f983ba13cc7f40a820df8dd8cf20b54d refs/heads/master
9a3184e2f983ba13cc7f40a820df8dd8cf20b54d refs/heads/master

PACK.......p..x...Kj.0...: (and so on...)

简单地用vim删除第四行就解决了这个问题。

转到颤振文件夹下,然后,

试试看:

git gc --prune=now

git remote prune origin

git pull

当Mac上的一个开发人员创建了一个分支,分支名称中带有大于“>”符号时,我们遇到了这个问题。

这在TeamCity和运行SourceTree的基于Windows的本地计算机上造成了问题。BitBucket让它顺利通过。

为了解决这个问题,用户删除了分支并重新创建了它。这很简单。

 # remove the reference file of the branch "lost"
 rm -fv ./.git/refs/remotes/origin/feature/v1.6.9-api-token-bot-reader
 
 # git clear everything 
 clear ; git reset HEAD --hard ; git clean -xdf ; 

 # subdue the current branch and pull all changes from the remote
 clear ; git fetch --all -p ; git pull --all --rebase ; clear ; git branch -a

 # git will "know" how-to handle the issue from now on
 #     From github.com:futurice/senzoit-www-server
 # * [new branch]      feature/v1.6.9-api-token-bot-reader ->
 # origin/feature/v1.6.9-api-token-bot-reader

 # and push your local changes
 git push