[plt-dev] Re: Git dummy needs help [was: Release for v5.0 has begun]

From: Eli Barzilay (eli at barzilay.org)
Date: Wed May 19 04:48:32 EDT 2010

On May 19, Michael Sperber wrote:
> Sorry if this is totally stupid.  I was hoping to be able to clone
> my local repo to a "release repo" where I test the release, but I
> can't seem to be able to clone anything but the "master" branch:
> kramer[2] cd ~/build/plt/
> kramer[3] git branch -a
> * master
>   remotes/origin/HEAD -> origin/master
>   remotes/origin/master
>   remotes/origin/release
>   remotes/origin/ryanc/sp-parser-tools
>   remotes/origin/samth/match-for
>   remotes/origin/samth/match-syntax-parse
>   ...

BTW -- those branches are gone on the server, run this to lose your
copy of them:

  git remote prune origin

> I was hoping "git clone" would ... clone or something in the sense
> of "create a copy with everything from the original repository", but
> that doesn't seem to be the case.

It is -- it looks like you've missed `git checkout' command.  In the
above clone (probably in the others too, but it was too noisy to
follow all the details), you just need to do this:

  git checkout release

After that, `git branch' will show you that you have the `release'
branch checked out with a star next to the name.

> I'm also getting the impression I don't understand how git branch
> names work.  Help would be much appreciated ...

In the above list, you asked it to show you all of the branches that
you have.  The most relevant there is:

> * master

which is the one that is checked out (has a "*"), and it is local.
Remote branches are just a tool to keep track of where the remote has
a certain branch -- so this:

>   remotes/origin/master

is the name of your clone's record of where the `master' branch of the
`origin' remote repository is at.  Also, your `master' branch is said
to be tracking the "remotes/origin/master" branch -- so if you run
`git pull' etc, that's where it will take the changes from (after it
updates this to match what's on the remote).

If you add `-vv', it will show you where the tip is at and which
branch it tracks, so you'll see these two as:

  * master                 <commit> [origin/master] <message>
    remotes/origin/master  <commit> <message>

you'll be able to see that the point to the same commit SHA1, and it
also shows you that `master' tracks `origin/master'.  (Git has a way
to guess which branch you're talking about, so if you use
`origin/master' it will guess that its `remotes/origin/master', and it
will also guess that if you give it just `origin'.)

>   remotes/origin/release

Finally, this is your copy of the release branch on the main
repository.  When you usually do something like

  git checkout release

it will tell you that `release' doesn't exist -- but because your
repository knows about a remote branch called `release', this will
create a local `release' branch and make it track the remote one.  It
shows you that by saying something like:

  Branch release set up to track remote branch release from origin.

when you do it the first time you do that checkout.  Later, when you
use `git checkout' to switch back and forth between the two, it won't
say that since it already exists.

(Most of this is described in the text I wrote.)

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

Posted on the dev mailing list.