git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: master^ is not a local branch -- huh?!?

From
RGRon 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
Previous: Junio C HamanoNext: Petr Baudis
Message 8 of 24 in “Re: master^ is not a local branch -- huh?!?”
  1. Steve DiverFeb 1, 2010
  2. Junio C HamanoFeb 1, 2010
  3. Sergei OrganovFeb 1, 2010
  4. Ron GarretFeb 1, 2010
  5. Petr BaudisFeb 1, 2010
  6. Nicolas PitreFeb 1, 2010
  7. Junio C HamanoFeb 1, 2010
  8. Ron GarretFeb 1, 2010
  9. Petr BaudisFeb 2, 2010
  10. Ron GarretFeb 2, 2010
  11. Junio C HamanoFeb 2, 2010
  12. Ron GarretFeb 2, 2010
  13. J. Bruce FieldsFeb 2, 2010
  14. Ron GarretFeb 2, 2010
  15. J. Bruce FieldsFeb 3, 2010
  16. Nicolas PitreFeb 2, 2010
  17. Ron GarretFeb 2, 2010
  18. Nicolas PitreFeb 2, 2010
  19. tytso@mit.eduFeb 2, 2010
  20. Junio C HamanoFeb 2, 2010
  21. Junio C HamanoFeb 2, 2010
  22. Nicolas PitreFeb 1, 2010
  23. Jay SoffianFeb 1, 2010
  24. Steve DiverFeb 1, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.