Subject: Re: Remote branchs -- how can I check them out?

From: Jakub Narebski <[email-masked]>
Date: Sun, 30 Jan 2011 08:35:19 -0800 (PST)

João Paulo Melo de Sampaio <[email-masked]> writes:

> Hello, people.
> 
> When I just cloned git using
> 
>     git clone git://git.kernel.org/pub/scm/git/git.git
> 
> and I type
> 
>     git branch
> 
> it shows me I have only the 'master' branch in my local repository
> 
>     * master
> 
> and when I type
> 
>     git branch -a
> 
> it shows that there's all these branches remotely
> 
>     * master
>       remotes/origin/HEAD -> origin/master
>       remotes/origin/html
>       remotes/origin/maint
>       remotes/origin/man
>       remotes/origin/master
>       remotes/origin/next
>       remotes/origin/pu
>       remotes/origin/todo
> 
> What do I have to do to be able to see what's in the 'maint', 'next'
> and 'todo' branches, for example?

Those are so called "remote-tracking branches", i.e. refs which follow
branches in some remote repository.  For example 'remotes/origin/master'
follows branch 'master' in remote 'origin'.  By follow I mean here that
on "git fetch" (also "git pull" and "git remote update") these 
remote-tracking branches would get updated to their value at remote.
 
Now if you only want to check wah's in given branch (beside using
"git show <branch>", "git ls-tree <branch>", "git show <branch>:<file>")
you can use e.g.

  $ git checkout origin/next

to check out _state_ of remotr-tracking branch origin/next, landing
in so called "detached HEAD" state, or unnamed branch (no branch).

If you want to do some work based on given branch, you should create
new local branch based on remote-tracking one, e.g. via

  $ git checkout -b --track next origin/next

IIRC nowadays doiung simply

  $ git checkout -t next

should DWIM to do the same.

> And by the way, what are those branches all about? Their names
> suggests they are maintenance branches (where you keep backward
> compatibility with an older version?), the next version of git (1.7.4
> version?) and future features under implementation (the to-do list?).

It is described in "Notes from maintainer" which you can find in git
mailing list archives, in 'todo' branch of git repository, and on Git
Wiki.

* 'master' - stable development, new major version is cut from it
* 'next' - development branch, not everything that makes it here
           would be in next version.  Rewound on new major version.
* 'maint' - maintenance branch for last version, minor revisions are
            cut from this; only bugfixes, no new development
* 'pu' - proposed updates, merge of interesting topic branches,
         very unstable, used to review proposed features

* 'todo' - not wery well maintained TODO list, som scripts used e.g.
           to send "What's cooking..." emails to git mailing list
* 'html', 'man' - compiled documentation

todo, html and man are detached branches.

HTH
-- 
Jakub Narebski
Poland
ShadeHawk on #git