tags:

views:

167

answers:

3

So I have a project hosted on github. I created a branch on one computer, then pushed my changes to github with

git push origin branch-name

Now I am on a different computer, and I want to download that branch. So I tried

git pull origin branch-name

but all this did was overwrite my master branch with the changes in my new branch.

What do I need to do to properly pull my remote branch?

A: 

Create a new directory, and do a clone instead.

git clone (address of origin) (name of branch)

Seisatsu
You cannot clone _just a branch_ in Git. Only a full repository clone can done.
Alan Haggai Alavi
+1  A: 

You could use git remote like:

git remote fetch origin

and then setup a local branch to track the remote branch like below:

git branch --track [local-branch-name] origin/remote-branch-name

You would now have the contents of the remote github branch in local-branch-name.

You could switch to that local-branch-name and start work:

git checkout [local-branch-name]
ardsrk
+2  A: 

Thanks to a related question, I found out that that I need to "checkout" the remote branch as a new local branch, and specify a new local branch name.

git checkout -b newlocalbranchname origin/branch-name
Andrew
Yeah I tried it. This is easier compared to my solution.
ardsrk