git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Björn Steinbrink" <B.Steinbrink@gmx.de>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: Dmitry Potapov <dpotapov@gmail.com>,
	Michael J Gruber <git@drmicha.warpmail.net>,
	git@vger.kernel.org
Subject: Re: What are branches?
Date: Mon, 20 Apr 2009 18:06:33 +0200	[thread overview]
Message-ID: <20090420160633.GA17241@atjola.homenet> (raw)
In-Reply-To: <alpine.DEB.1.00.0904201621290.6771@intel-tinevez-2-302>

On 2009.04.20 16:25:38 +0200, Johannes Schindelin wrote:
> On Mon, 20 Apr 2009, Dmitry Potapov wrote:
> 
> > When you create a new commit, it is always belong to _one_ branch
> > and never to two or more branches.
> 
> Certainly you forgot about detached HEADs? And about the ability to
> create new branches which point to the _exact_ same commit as other
> branches? And about the option to delete the original branch, not
> removing the commit, or the other branches, at all?
> 
> No, this all shows: we _have_ a different branch model from most other
> VCSes, and we _obviously_ make that not clear enough.

Basically, git has no actual entities that I'd call "branches", it just
has named branch heads. The branches themselves are implicit in the
commit DAG.

If you go out, and look at a tree lit-up by the evil daystar, branches
start at the trunk and end at their tip. The trunk isn't part of the
branch. And as e.g. a SVN user, you can use an analogy and say "There's
branch XYZ and it has these three commits", ignoring commits from the
trunk or other branches leading up to this one. And you can even ask SVN
which commits make up that branch, by using a "stop on copy" feature
(because that copy usually tells where the branching point is).

Let's take this history:

A---B---C---D (refs/heads/master)
 \
  E---F---G (refs/heads/foo)
       \
        H---I---J (refs/heads/bar)

The branches might be thought of to contain these commits:

master: A, B, C, D
foo: E, F, G
bar: H, I, J

Because those commits are (from a task oriented view) what makes those
branches. If branch "bar" implements feature Y, then the commits A, E
and F might not be interesting when talking about the branch in the
context of the feature it implements.

With SVN you could do:
svn log --stop-on-copy .../bar

Which automatically ignores commits that are on other branches.

With git you need:
git log foo..bar

Which gives the same result, but you need to be more explicit about what
you want to ignore. Because git just sees branch heads, not branches.
The same "you need to think a bit more/different" applies to merging
branches. As svn has just glorified cherry-picking, you can ignore the
whole history leading up to a branch, and still think of just "this
branch does this task", and "merge" that branch. For git, that obviously
won't do, you need to see the branch as it's embedded into the history.
I'm not saying this is bad, as it gives you a more useful history, and
more flexibility, but it is definitely different from at least one wide
spread system.

The only thing I'm aware of where git really draws a line between
"branches" and branch heads is git checkout. You can checkout a "branch"
using its name:
	git checkout master

But using the name of the branch head, will detach HEAD:
	git checkout refs/heads/master

(The quotes are there because this "branch" doesn't match the definition
of a branch as I used it earlier...)


So basically, we don't have explicit branches, just a mechanism to
control where the branches grow.

Björn

  reply	other threads:[~2009-04-20 16:08 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-19 15:17 What are branches? Johannes Schindelin
2009-04-19 15:24 ` Michael Witten
2009-04-19 22:10 ` Tuncer Ayaz
2009-04-19 22:29   ` Johannes Schindelin
2009-04-19 22:34     ` Tuncer Ayaz
2009-04-20 11:32 ` Dmitry Potapov
2009-04-20 12:07   ` Michael J Gruber
2009-04-20 13:24     ` Dmitry Potapov
2009-04-20 13:52       ` Michael J Gruber
     [not found]         ` <200904201614.07735.fge@one2team.com>
2009-04-20 14:27           ` Michael J Gruber
2009-04-20 18:40         ` Dmitry Potapov
2009-04-20 20:58           ` Junio C Hamano
2009-04-20 22:08             ` Marius Vollmer
2009-04-21  0:53               ` Junio C Hamano
2009-04-21 11:41             ` Dmitry Potapov
2009-04-20 14:25       ` Johannes Schindelin
2009-04-20 16:06         ` Björn Steinbrink [this message]
2009-04-20 18:59           ` Jakub Narebski
2009-04-20 20:23             ` Björn Steinbrink
2009-04-24 13:08               ` Jakub Narebski
2009-04-24 16:29                 ` Björn Steinbrink
2009-04-20 18:47         ` Dmitry Potapov
2009-04-20 19:19           ` Johannes Schindelin
2009-04-20 19:24             ` Michał Kiedrowicz
2009-04-20 20:16             ` Dmitry Potapov
2009-04-20 21:04           ` Björn Steinbrink
2009-04-20 16:13       ` Brian Gernhardt
2009-04-25 11:11 ` Felipe Contreras

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=20090420160633.GA17241@atjola.homenet \
    --to=b.steinbrink@gmx.de \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=dpotapov@gmail.com \
    --cc=git@drmicha.warpmail.net \
    --cc=git@vger.kernel.org \
    /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).