-1

When I git branch I only see 'master', 'v2/branch1', and 'v2/master', but when I git branch -r I see a lot more branches that come after origin. If I were to want to work in one of these remote branches, do I just git checkout ? Would that automatically change my working directory and index to that branch and set up the tracking branch for me?

love
  • 3,203
  • 2
  • 15
  • 34
akantoword
  • 2,534
  • 7
  • 24
  • 39
  • 6
    Possible duplicate of [Checkout remote Git branch](http://stackoverflow.com/questions/1783405/checkout-remote-git-branch) – Vitor Jun 08 '16 at 17:43

2 Answers2

0

git fetch remote

git checkout --track -b local_branch_name origin/branch_name

Shravan40
  • 7,746
  • 5
  • 27
  • 45
  • can you explain the purpose of fetching? Doesn't my git branch -r mean that I'm already tracking all of these remote branches? – akantoword Jun 08 '16 at 17:53
0

Follow the below steps:

git branch -r
git checkout <branch name>
Siddharth Sunil
  • 223
  • 2
  • 10