使用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 fetch--prune为我修复了这个错误:

[marc.zych@marc-desktop] - [~/code/driving] - [Wed May 10, 02:58:25]
[I]> git fetch
error: cannot lock ref 'refs/remotes/origin/user/janek/integration/20170505': 'refs/remotes/origin/user/janek/integration' exists; cannot create 'refs/remotes/origin/user/janek/integration/20170505'
From github.com:zooxco/driving
 ! [new branch]            user/janek/integration/20170505 -> origin/user/janek/integration/20170505  (unable to update local ref)
From github.com:zooxco/driving
[marc.zych@marc-desktop] - [~/code/driving] - [Wed May 10, 02:58:30]
[I]> git fetch --prune
 - [deleted]               (none)     -> origin/user/janek/integration

不过,这假设有问题的分支已在远程删除。

您也可以将其添加到~/.gitconfig中,以在运行git fetch时自动修剪:

[fetch]
    prune = true

其他回答

我在作曲家更新方面也遇到了同样的问题。但对我来说,只有在我清除了composer缓存并删除了供应商文件夹的内容后,它才起作用:

rm -rf vendor/*
git gc --prune=now
git pull
composer clear-cache
composer update my/package

对我来说,它可以从.git/refs/remotes/origin/文件夹中删除引发错误的文件。

如果有人觉得这很有用,我会长期遇到这个问题,虽然不是经常出现,因为我在Dropbox中有git目录,从Dropbox中删除了它,一切都很好。

今天刚遇到问题。

故障排除方法:使用Windows服务器上的SourceTree,您可以尝试以管理员身份运行它。这解决了我在域中Windows Server 2012 R2上的Atlassian源树2.1.2.5上“无法更新本地引用”的问题。

如果您也可以复制这种情况,则证明问题是由权限问题引起的。最好深入研究并找到根本原因-可能某些特定文件是由其他用户等拥有的-否则会有一个不受欢迎的副作用:您将不得不以管理员身份运行SourceTree。

我用的是git prune的起源,这就完成了工作。