Re: master^ is not a local branch -- huh?!?
- From
- Ron Garret <ron1@flownet.com>
- Date
- Feb 1, 2010, 23:56 UTC
- Message-ID
- <ron1-ABA66E.15563101022010@news.gmane.org>
- In-Reply-To
- <7vwrywplxz.fsf@alter.siamese.dyndns.org>
In article <7vwrywplxz.fsf@alter.siamese.dyndns.org>, Junio C Hamano <gitster@pobox.com> wrote:
Show 14 quoted lines
> Ron Garret <ron1@flownet.com> writes: > > >> For my rather fresh eye it looks more like unnamed (anonymous?) branch > >> than a temporary one. Doesn't detached HEAD behave exactly like a > >> regular HEAD but pointing to the tip of an unnamed branch? > > > > I strongly concur with this. > > > > And as long as I'm weighing in, it would also help to prevent confusion > > if it were made clear that this unnamed branch doesn't actually come > > into existence unless and until you do a commit. > > This shows that you are still thinking a branch is a line (or multiple > lines). It is not.
The git user's guide says it is:
"When we need to be precise, we will use the word "branch" to mean a line of development..."
But I understand that a branch is not necessarily a line. In general it's a DAG. I get that.
The manual goes on to say:
"...and "branch head" (or just "head") to mean a reference to the most recent commit on a branch."
There are two ways this can be interpreted:
1. A commit pointed to by a branch head cannot have any descendants. Because if it did it would not be the most recent commit on that branch, and by definition a branch head must point at the most recent commit.
2. Any commit can be considered a branch head for a branch consisting of (for example) the transitive closure of its ancestors.
(Note that if I were being really strict with my terminology I would have to say: any commit can be considered the most recent commit for a branch consisting of... Because a branch head by definition is a *reference* to a commit, so strictly speaking a commit cannot be a branch head. The problem is that there are three concepts in play, but only two terms by which to refer to them.)
I personally think interpretation #1 makes more sense, and is a better match to most people's intuitions about what it means to be a branch head. But in neither case does simply moving HEAD "create" a branch. Even under interpretation 2, all those anonymous branches were there all along. You don't "create" anything, temporary or otherwise, simply by moving HEAD.
rg