无法使用git pull"无法找到远程参考xxx"

dj1*_*008 21 git

我想出了一个关于git pull的问题.

首先,我在"test_http_1204"分支,

root@inception-server-Quantal:~/bosh# git branch
              master
            * test_http_1204
              ubuntu1204
Run Code Online (Sandbox Code Playgroud)

然后我使用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
Run Code Online (Sandbox Code Playgroud)

但是,我可以在我的远程仓库"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
Run Code Online (Sandbox Code Playgroud)

并且.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
Run Code Online (Sandbox Code Playgroud)

我想根本原因可能是.git/config中缺少[branch"test_http_1204"],但是当我手动将这些行添加到.git/config时,它仍然无效.

[branch "test_http_1204"]
        remote = m109bosh
        merge = refs/heads/test_http_1204
Run Code Online (Sandbox Code Playgroud)

我根本不知道.你能告诉我怎么解决吗?谢谢!

tor*_*rek 21

基于git ls-remote输出(在评论中,现在已经消失 - 它在评论中不太合适)它看起来像遥控器曾经有一个名为的分支test_http_1024,但不再是.

换句话说,控制遥控器的人做了git branch -d(或类似的东西)删除他们的分支test_http_1024.这意味着当你询问git pull那个分支的内容时,它可以告诉你的全部是:"呃?什么?什么分支?" :-)

当你查看自己的一组远程分支时,你可以看到它们曾经有一个分支test_http_1024(你的git复制到remotes/m109bosh/test_http_1204它,当它存在时返回).但他们可以随时添加或删除分支.

如果您运行git fetch -p m109boshgit 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
Run Code Online (Sandbox Code Playgroud)

有两条不同的 url =线.据推测其中一个已经过时了.(git fetch使用第一个,所以也许第二个是你想要的那个.)