I'm struggling to checkout a remote branch that I know it exists, because it show up with git ls-remote:
$ git ls-remote
242d56fbd8d8af67df3157bd047252f5580e3df8    HEAD
242d56fbd8d8af67df3157bd047252f5580e3df8    refs/heads/master                                         
517af0f6de9a3db846c4bde693a11ccb52092aee    refs/heads/foobar
When I try to checkout, I get an error:
$ git checkout refs/heads/foobar
error: pathspec 'refs/heads/foobar' did not match any file(s) known to git
I've tried all sorts of things to no avail:
- git fetch --alldoesn't change anything, neither does- git fetch origin
- git branch -v -adoesn't show it
Going through many SO answers, I finally stumbled upon something that worked, but I have no clue why:
git fetch origin foobar:foobar
