0

I have 3 branches that I see in bit-bucket, one master and 2 branches other developers have worked on.

I would like to take the latest branch, make a few changes, and merge it into the master. This branch is called "Updated_model_,_sources" when I review my remote branches (git branch -r) I get:

origin/HEAD -> origin/master
origin/master

So I don't see it there, but when I try git ls-remote origin I get:

longcodeblablabla HEAD
longcodeblablabla refs/heads/Updated_model_,_sources
..

so I see it's there, now the thing is - I just cannot checkout this branch! I tried a lot of different ways to do so but I keep getting:

error: pathspec 'refs/heads/Updated_model_,_sources' did not match any file(s) known to git

(tried it without the path folders as well).

PS - I did not perform a standard clone, the project piled up to be really heavy so it got stuck in the clone, so I used git clone --depth 9 blabla@blabla.com.

Zoe
  • 27,060
  • 21
  • 118
  • 148
Roman
  • 11
  • 3

1 Answers1

1

By default, when doing a shallow clone you only get the single branch that the remote's HEAD points to (i.e. master). You need to fetch the remote branch you want in order to check it out:

git fetch origin Updated_model_,_sources:Updated_model_,_sources

Note that this will grab all ancestors of the branch, which, given that youth used the --depth option with git clone, may not be what you want. So, you can pass the --depth option to git fetch as well. However, I would highly suggest that you just do a full clone; otherwise, you will be left with a few disconnected branches. Shallow clones are just funky, as you get problems like the one you are seeing now.

David Deutsch
  • 17,443
  • 4
  • 47
  • 54
  • OK I fetched, but I tried "git checkout Updated_model_,_sources" and got the same error.. :/ what can be the problem? – Roman Feb 03 '16 at 09:15
  • @Roman, I have updated the answer; note that I altered the `git fetch` a bit. But as I say in the answer, my recommendation would be to just do a full clone. – David Deutsch Feb 03 '16 at 12:11
  • Thanks, I appreciate it but unfortunately I cannot - whenever I try to clone I get this message: error: RPC failed; result=52, HTTP code = 0 fatal: The remote end hung up unexpectedly I suspect that the project is too big - BTW depth 9 works but depth 10 does not.. I tried increasing the buffer size, but it didn't help also.. :/ – Roman Feb 03 '16 at 13:53