Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fail to use git pull "Couldn't find remote ref xxx"

Tags:

I come up with a problem about git pull.

Firstly, I am in "test_http_1204" branch,

root@inception-server-Quantal:~/bosh# git branch
              master
            * test_http_1204
              ubuntu1204

Then I use git pull, and got an error message,

 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

But, I can find branch "test_http_1204" in my remote repo "m109bosh",

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

And, the content of .git/config is shown below:

  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

I guess the root cause maybe the missing of [branch "test_http_1204"] in the .git/config, but when I add these lines to .git/config manually, it still does not work.

[branch "test_http_1204"]
        remote = m109bosh
        merge = refs/heads/test_http_1204

I have no idea about that. Could you please tell me how to fix it? Thanks!

like image 517
dj199008 Avatar asked Feb 08 '14 06:02

dj199008


1 Answers

Based on git ls-remote output (was in comment, now gone - it doesn't fit very well in comments) it looks like the remote used to have a branch named test_http_1024, but no longer does.

In other words, whoever controls the remote did a git branch -d (or something equivalent) to delete their branch test_http_1024. This means that when you ask git pull for the contents of that branch, all it can tell you is: "eh? what? what branch?" :-)

When you look at your own set of remote branches, you can see that they used to have a branch test_http_1024 (which your git copied to remotes/m109bosh/test_http_1204, back when it existed). But they can add or delete branches whenever they want.

If you run git fetch -p m109bosh or git remote update --prune m109bosh, your own git will delete its (old, stale) copy of their test_http_1024 branch. (You might not want to do this if you're still using it for something.)


A perhaps more important issue is that in:

[remote "m109bosh"]
    url = https://github.com/m1093782566/bosh-cloudstack-cpi.git
    fetch = +refs/heads/*:refs/remotes/m109bosh/*
    url = https://github.com/m1093782566/bosh.git

there are two different url = lines. Presumably one of them is out of date. (git fetch uses the first one, so perhaps the second is the one you want.)

like image 128
torek Avatar answered Sep 22 '22 08:09

torek