Reputation: 660
I have the master branch from a repository on Github cloned on my machine. There are other existing branches in this repository that I would like to be able to switch to and use. I'm trying to use the command:
git branch --track nameOfBranch origin/nameOfBranch
This isn't working for me. I get the error:
error: the requested upstream branch (URL) does not exist
Basically I need to create the branch on my local machine and tie it to an existing branch. Thank you for your help!
Upvotes: 0
Views: 89
Reputation: 1315
I think I understand what you want. To create a local tracking branch that you can work on the following should work.
First you need to clone the repository:
$ git clone git://thisismyrepo.com/project
$ cd project
Next find the branch you want to be working on:
$ git branch -a
That will output all the branches in your repo. Next you want to switch over to the branch you want to work on by:
$ git checkout origin/examplebranch
In order to work on that branch you can then do:
$ git checkout -b examplebranch origin/examplebranch
That should cause it to track and allow you to work on it as a local branch. Hope this helps.
Upvotes: 2