我想出了一个关于 git pull 的问题。
首先,我在“test_http_1204”分支,
root@inception-server-Quantal:~/bosh# git branch
master
* test_http_1204
ubuntu1204
然后我使用git pull,得到了一条错误信息,
root@inception-server-Quantal:~/bosh# git pull m109bosh test_http_1204
fatal: Couldn't find remote ref test_http_1204
Unexpected end of command stream
但是,我可以在我的远程仓库“m109bosh”中找到分支“test_http_1204”,
root@inception-server-Quantal:~/bosh# git branch -a
master
* test_http_1204
ubuntu1204
remotes/m109bosh/master
remotes/m109bosh/patch-1
remotes/m109bosh/test_http_1204
remotes/m109bosh/ubuntu1204
remotes/origin/HEAD -> origin/master
remotes/origin/floating_dns_registry
remotes/origin/http_stemcell_uploader
remotes/origin/master
remotes/origin/squashed
remotes/origin/ubuntu1204
remotes/origin/upstream
并且,.git/config 的内容如下所示:
root@inception-server-Quantal:~/bosh# cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = https://github.com/cloudfoundry-community/bosh-cloudstack-cpi.git
[branch "master"]
remote = origin
merge = refs/heads/master
[branch "ubuntu1204"]
remote = origin
merge = refs/heads/ubuntu1204
[remote "m109bosh"]
url = https://github.com/m1093782566/bosh-cloudstack-cpi.git
fetch = +refs/heads/*:refs/remotes/m109bosh/*
url = https://github.com/m1093782566/bosh.git
我猜根本原因可能是 .git/config 中缺少 [branch "test_http_1204"],但是当我手动将这些行添加到 .git/config 时,它仍然不起作用。
[branch "test_http_1204"]
remote = m109bosh
merge = refs/heads/test_http_1204
我对此一无所知。你能告诉我如何解决吗?谢谢!
最佳答案
基于 git ls-remote
输出(在评论中,现在不见了 - 它不太适合评论)它看起来像远程曾经有一个名为 test_http_1024
的分支,但不再存在。
换句话说,控制 Remote 的人执行了 git branch -d
(或类似的东西)来删除他们的分支 test_http_1024
。这意味着当您向 git pull
询问该分支的内容时,它只能告诉您:“嗯?什么?什么分支?” :-)
当您查看自己的一组远程分支时,您可以看到它们曾经有一个分支 test_http_1024
(您的 git 将其复制到 remotes/m109bosh/test_http_1204
,存在时返回)。但他们可以随时添加或删除分支。
如果您运行 git fetch -p m109bosh
或 git remote update --prune m109bosh
,您自己的 git 将删除其(旧的、陈旧的)副本>test_http_1024
分支。 (如果您仍在使用它,您可能不想这样做。)
也许更重要的问题是:
[remote "m109bosh"]
url = https://github.com/m1093782566/bosh-cloudstack-cpi.git
fetch = +refs/heads/*:refs/remotes/m109bosh/*
url = https://github.com/m1093782566/bosh.git
有两行不同 url =
行。大概其中之一已经过时了。 (git fetch
使用第一个,所以也许第二个就是您想要的。)
关于git - 无法使用 git pull "Couldn' t 找到远程引用 xxx”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21642694/