Solution already found in this thread: The branch name is the same as a folder name in the repository.
I check out a git repo with different branches
$ git clone <repo> .
$ git branch -a
* b1
remotes/origin/HEAD -> origin/b1
remotes/origin/b1
remotes/origin/b2
remotes/origin/b3
There's no master branch, the default is b1
$ cat .git/config
...
[branch "b1"]
remote = origin
merge = refs/heads/b1
I am using git version 1.9.1.
According to this thread I only need to git checkout b2
to checkout and track the remote branch origin/b2
with a local branch b2
$ git checkout b2
Branch b2 set up to track remote branch b2 from origin.
Switched to a new branch 'b2'
The branch is added to .git/config
But if I try to checkout another branch...
$ git checkout b3
...nothing happens. No error message, no checkout to the branch b3
.
I can do
$ git checkout -b b3 origin/b3
Branch b3 set up to track remote branch b3 from origin.
Switched to a new branch 'b3'
What could be the difference between the two branches so that the checkout
behaves differently?
Could it be with which git version a branch was created/committed/pushed?
UPDATE:
The branch names used in this post alias the real branch names (which I'd like to avoid showing here).
A checkout of a non-existing branch shows:
$ git checkout invalid_branch
error: pathspec 'invalid_branch' did not match any file(s) known to git.