0

there are 2 machines, which i use.

i have cloned one git repository of application which i work on.

on machine A i have cloned this repo, have worked on various features on different branches which i created and committed and pushed remotely.

So remotely i have 3 branches now, one is the master, rest 2 branch1, branch2 of my features.

on machine 2 i have cloned the repository 'master' branch.

my question is how i get the branch1, branch2 on my machine 2 .

so that i can commit stuff from machine 2 too.

thanks in advance.

(sorry for bad english)

jospratik
  • 1,286
  • 10
  • 18

1 Answers1

3

you can

git fetch --all
git branch -r # will list all remote branches
git checkout <branch> # notice that the branch name should not have leading 'origin', it is the *local* branch name

git will create local branch tracking the remote branch with same name.

Also check this.

Community
  • 1
  • 1
dyng
  • 2,621
  • 19
  • 22
  • thanks for the reply. it worked. so if i commit and push my changes from machine 2 , i will have to do a 'git pull branch_name_i_commited_in'. am i right ? – jospratik Jun 22 '13 at 14:30
  • @jospratik Yes, you are right. Also check [this](http://stackoverflow.com/questions/3357122/git-pull-vs-git-fetch-git-rebase), it introduced a better practice of using `git pull` and `git pull --rebase` selectively. – dyng Jun 22 '13 at 15:19