git pull失败”;无法解析引用“&引用;无法更新本地引用";

git pull失败”;无法解析引用“&引用;无法更新本地引用";,git,git-pull,Git,Git Pull,使用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 (u

使用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 remote prune origin,但没有任何帮助。

尝试使用以下工具清理本地存储库:

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

曼吉特gc(1):

git gc-清理不必要的文件并优化本地存储库
git gc[--aggressive][--auto][--quiet][--prune=|--no prune]
在当前存储库中运行许多内务管理任务,例如压缩文件修订
(以减少磁盘空间并提高性能)并删除可能已删除的无法访问的对象
从先前的git add调用创建。
鼓励用户在每个存储库中定期运行此任务,以维护良好的磁盘
空间利用率高,运行性能好。
曼吉特遥控器(1):

git-remote-管理跟踪存储库集
git远程修剪[-n |--干运行]
删除下所有过时的远程跟踪分支。这些陈腐的树枝已经腐烂了
已从引用的远程存储库中删除,但仍在中本地可用
“遥控器/”。

这帮我完成了任务:

git gc --prune=now

我也遇到了同样的问题,通过查看出错的文件解决了这个问题:

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

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

我也遇到过这种情况。就我而言,坏裁判是大师级的,我做了以下几点:

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

这使得git恢复了ref文件。在那之后,一切又恢复了正常。

对我来说,我有一个本地分支名为
feature/phase2
,远程分支名为
feature/phase2/data model
。命名冲突是问题的原因,因此我删除了我的本地分支(如果它有任何需要保留的内容,您可以重命名它)

对我来说,它可以从文件夹
中删除引发错误的文件。git/refs/remotes/origin/
我在composer update中也遇到了同样的问题。但对我来说,它只有在我清除composer缓存并删除供应商文件夹的内容后才起作用:

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

我能和你一起工作

git remote update --prune

我也有同样的问题。我遵循以下步骤

1) 将有问题的分支机构切换到其他分支机构

2) 删除该分支

3) 再次结账


注意:-您可以隐藏未提交的更改并将其放回原处。

在尝试从
git bundle
创建的文件进行克隆时遇到此问题,其他答案均无效,因为我无法克隆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简单地删除第四行就解决了这个问题。

简单地回答这个问题,当您的本地用户有一些关于远程设备的信息,并且有人更改了使远程设备和您的更改不同步的内容时,就会出现这个问题

我遇到这个问题是因为有人删除了远程分支,并再次创建了同名分支

要处理此类问题,请从远程执行pull或fetch

git remote prune origin
或者,如果您正在使用任何GUI,请从远程执行获取

git remote prune origin

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


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

在我的情况下,在我删除目录
.git
下的所有删除参考文件后,问题就解决了

如果您查看该消息,它会告诉您需要删除哪些文件(特别是)

要删除的文件位于
.git/refs/remotes

我刚刚删除了那里的所有文件,并运行了gc prune

git gc --prune=now

之后,一切正常。

有相同的消息,但有一个目录,拉取时得到一个失败的消息

git——这也帮不了我。 原来有一个文件与远程创建的目录同名

必须转到.git\logs\refs\remotes\origin并删除区域设置文件-然后再次拉取,一切正常。

如果
git gc--prune=now
对您没有帮助。(像我一样倒霉)

我所做的是在本地删除该项目,然后重新克隆整个项目。

尝试以下操作:

git pull origin Branch_Name
分支机构\u Name
,您当前所在的分支机构

如果只执行一个
git pull
,那么它也会提取所有其他创建的分支名称

这就是你得到这个的原因:

! [new branch]      split-css  -> origin/split-css  (unable to update local ref)
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

今天遇到了问题

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


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

执行以下命令:

rm .git/refs/remotes/origin/master

git fetch

git branch --set-upstream-to=origin/master
以防万一,如果你需要知道
.git/refs/remotes/origin/master
,您可以阅读remotes部分 在


在删除存储库并使用相同的名称创建存储库时遇到相同的问题。只有当我重新设置远程url时,它才起作用,如下所示

git远程设置url源[git]
 # remove the reference file of the branch "lost"
 rm -fv ./.git/refs/remotes/origin/feature/v1.6.9-api-token-bot-reader

 # get all the branches from the master
 git fetch --all

 # 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
rm .git/refs/remotes/origin/master

git fetch

git branch --set-upstream-to=origin/master
git remote -v
git gc --prune=now

git remote prune origin

git pull
rm .git/refs/remotes/origin/master
git fetch
git gc --prune=now
git remote prune origin
git fetch --prune
git fetch --all
git pull
rm .git/refs/remotes/origin/master
git fetch
git branch --set-upstream-to=origin/master master
git pull