On Mar 25, 6:11 pm, Pito Salas <r...@salas.com> wrote:
> Thanks!
>
> So even though the branch is in the local repo, I can't use the files
> locally without creating a local tracking branch.
>
> And git checkout as well as git branch only work locally, always.
>
> Yes?

You could actually check out the remote branch (git checkout origin/
ymlsupport) - you'd get all the files in the state on that branch, but
you'd be in a detached HEAD state - you're not on a local branch that
you can make commits to. That's why you want to make that local
tracking branch.  If you keep that branch around, you'll probably want
to keep merging after each time you fetch (git checkout ymlsupport;
git merge origin/ymlsupport).

The reason that git detaches HEAD when you check out a remote branch
is that the remote branch, though it exists within your repository, is
intended to indicate the position of that branch in the remote
repository.  It's updated when you fetch from there, so sometimes it's
behind, but it's always showing you where the remote's branch was the
last time you looked. It doesn't make sense for you to commit to that
branch - clearly you're not actually putting the commit in the
remote's repository, so the remote branch shouldn't move.

It can be useful to do that detached HEAD checkout - say you just
wanted to have a look at origin/ymlsupport, make sure everything was
okay there, then pop back to what you were doing. No need to create a
branch if you're just doing it once.

Jeffrey

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To post to this group, send email to git-us...@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.

Reply via email to