3

I have a remote branch:

git branch -a
*master
 remotes/origin/develop

Can I checkout to remotes/origin/develop ? Or should I always create clone of remote branches locally?

Max Koretskyi
  • 101,079
  • 60
  • 333
  • 488
  • `git pull origin develop` will create a local branch `develop` which tracks the remote one. – Alessandro Vendruscolo Jan 22 '14 at 09:11
  • In reasonably current versions of git (>= 1.7.something I think), you can just `git checkout develop` to create a local tracking branch. If this doesn't work, `git checkout -b develop --track origin/develop` should at least work. – torek Jan 22 '14 at 10:08

1 Answers1

1

I believe you need to clone your remote branches locally if you want to make changes in the remote. When you checkout a remote branch by issuing git checkout remotes/origin/develop, you will go into a detached HEAD state, which essentially means you are not on any branch right then.

gravetii
  • 9,273
  • 9
  • 56
  • 75
  • Right, `detached HEAD` is exactly where I got when I tried. Can you please elaborate on why this happens? – Max Koretskyi Jan 22 '14 at 09:19
  • It basically means you are not bound to a branch. You are just referring to one particular commit. Check the Detached Head section in this link: http://git-scm.com/docs/git-checkout – gravetii Jan 22 '14 at 09:36