git clone
has already cloned every branch to your repository. But it hasn't created local branches for all of them, just master
. The rest are in remote tracking branches which are prefixed with the name of the remote, origin
. You can see them with git branch -r
.
The remote's master branch is in the remote tracking branch origin/master
. Their dummy
is in origin/dummy
. Your repo looks something like this.
[origin/master]
A - B - C - D [master]
\
E - F [origin/dummy]
Cloning has created a local master
branch, but no local dummy
.
By default, when you make a new branch it is off of the current branch. If you had master
checked out, which you would right after cloning, then git checkout -b dummy
make a branch called dummy
off of master
.
$ git checkout -b dummy
[dummy]
[origin/master]
A - B - C - D [master]
\
E - F [origin/dummy]
That's not right. We want it off origin/dummy
.
After deleting the incorrect dummy, git branch -d dummy
, we can checkout origin/dummy and then make the branch.
git checkout origin/dummy
git checkout -b dummy
[origin/master]
A - B - C - D [master]
\
E - F [origin/dummy]
[dummy]
Or as a shorthand, we can pass in where we want to branch from
git checkout -b dummy origin/dummy
Or, even shorter, you can simply checkout your non-existent dummy
branch and Git will assume it's supposed to be the local branch of origin/dummy
. This is controlled by the --guess
option, on by default.
git checkout dummy
Branch 'dummy' set up to track remote branch 'dummy' from 'origin'.
Switched to a new branch 'dummy'
See Working With Remotes in Pro Git for more.