Reputation: 1865
I forked a repo on github but they than created another branch inside that repo. When I do git fetch upstream it does not create that branch in my repo. How do I do this?
Upvotes: 7
Views: 6020
Reputation: 44377
After you have done git fetch
and gotten the new remote branch origin/branchname
you can do
git checkout -t origin/branchname
This creates a local branch called branchname
that tracks the remote branch.
If you know for sure that the name of the remote branch is exactly origin/branchname
, and there is no other branch called branchname
on any other remotes you have, you can use the shorthand
git checkout branchname
An alternative syntax can be used if you want to name the local branch something different
git checkout -b local_branchname -t origin/branchname
Upvotes: 11
Reputation: 13574
git checkout <branchname>
Git automatically matches the branch names.
Upvotes: 1