git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@osdl.org>
To: walt <wa1ter@myrealbox.com>
Cc: git@vger.kernel.org
Subject: Re: git-bisect is magical
Date: Tue, 10 Jan 2006 18:58:56 -0800 (PST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0601101846170.3294@g5.osdl.org> (raw)
In-Reply-To: <dq1o88$1bm$1@sea.gmane.org>



On Tue, 10 Jan 2006, walt wrote:
>
> Linus Torvalds wrote:
> [...]
> > So when you say "git checkout origin", it actually _switches_ to the
> > origin branch (which is just my state) and checks that out.
> 
> I think we are finally homing in on the very roots of my ignorance!
> 
> When you use the word 'switches' my eyes go glassy, just like when
> my wife starts telling me everything I've done wrong today...

Ahhah.

> Please --> what am I switching *from* when I switch to 'origin'?
> (Think:  this guy is a total dumbshit!  How can I possibly dumb-
> down this basic knowledge any dumber?)

Ok, this clearly isn't described well enough in any docs, so let me try, 
and hopefully somebody (hint hint) will go "Ahh, I wish that had been 
described in xyz - here's a patch to do so".

Anyway, the notion of multiple "branches" aka "heads of development" is 
pretty ingrained in git. It's really how _everything_ subtle gets done 
(merging, you name it - sometimes the branch may be a temporary unnamed 
head that is just inside a script, but the _concept_ is always there).

There's one _special_ branch, which is the "active" one. The only git 
trees without an active branch are the so-called "bare" git trees, which 
are the .git directory contents directly, without any checked-out state. 
Those are only used for distribution - no development can ever happen in 
them, because they simply don't have any active branch to do development 
_in_.

But for any normal git repository, you'll have one active branch, which is 
the one that your working directory actually represents. It's also the one 
we call "HEAD", since the HEAD thing is the thing that points to the 
active branch.

Your HEAD can point to _any_ branch, but the default one is called 
"master". That's the branch you get when you clone another repository, or 
when you just start a new git repository from scratch with "git-init-db".

But you can "switch" between branches at any time by just doing a simple 
"git checkout <branchname>". That will conceptually totally blow away your 
working directory contents (well, all of it that git knows about, anyway), 
and replace them with the contents that the _other_ branch contains. Now, 
I say "conceptually", because in practice this is heavily optimized, so 
that any files that don't change aren't actually re-written, so you can 
switch between two branches that are similar quite cheaply.

So when you did "git checkout origin", you basically blew away all the 
development you had done in the default "master" branch, and switched to 
_another_ branch. The "origin" branch is the one that is generated for you 
automatically when you clone a repository from somewhere else: it 
initially contains the state of that other repository at the time of the 
clone, and a "git pull origin" will actually both "fetch" that branch (so 
that the "origin" branch is kept up-to-date with the original source) 
_and_ merge that branch into your HEAD (normally "master").

> I know this is really bone-head-basic-stuff, but I'm quite sure
> that this lies at the heart of my confusion.
> 
> When I finally understand this kindergarten material I can graduate
> to first grade  :o)

Well, at least _some_ of this is described in Documentation/git-pull.txt 
and Documentation/tutorial.txt. So if you haven't looked into those 
before, try them now. And if you have, they clearly need more effort.

I'm really bad at documentation. I'm more than happy trying to answer 
emailed questions (at least if I get the feeling that the person asking 
the questions is really trying to learn, which you've done admirably), but 
that doesn't mean that I'm good at writing the docs. So I'm hoping that 
some of this can find itself into a FAQ or one of the existing docs, 
thanks to somebody else editing it..

		Linus

  parent reply	other threads:[~2006-01-11  2:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-09 22:41 git-bisect is magical walt
2006-01-09 23:38 ` Linus Torvalds
2006-01-10 19:19   ` walt
2006-01-10 19:42     ` Linus Torvalds
2006-01-10 19:45       ` Linus Torvalds
2006-01-10 20:43         ` walt
2006-01-10 21:17           ` Linus Torvalds
2006-01-11  1:50             ` walt
2006-01-11  2:47               ` Junio C Hamano
2006-01-11  2:58               ` Linus Torvalds [this message]
2006-01-11 18:07                 ` walt
2006-01-12 21:59                   ` Sytse Wielinga
2006-01-12 23:49                     ` walt
2006-01-09 23:39 ` Andreas Ericsson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.0601101846170.3294@g5.osdl.org \
    --to=torvalds@osdl.org \
    --cc=git@vger.kernel.org \
    --cc=wa1ter@myrealbox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).