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

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

From
SDSteve Diver <squelch2@googlemail.com>
Date
Feb 1, 2010, 22:34 UTC
Message-ID
<31a97741002011434t565824abiba52f3329258ec14@mail.gmail.com>
In-Reply-To
<alpine.LFD.2.00.1002011309020.1681@xanadu.home>
On 1 February 2010 18:12, Nicolas Pitre <nico@fluxnic.net> wrote:
Show 31 quoted lines
> On Mon, 1 Feb 2010, Junio C Hamano wrote:
>
>> I do not think we need yet another term "scratchpad" for this, but what is
>> important is that both introductory and full documentation explain the
>> detached HEAD well.
>>
>> Currently we say:
>>
>>     Detached HEAD
>>     -------------
>>
>>     It is sometimes useful to be able to 'checkout' a commit that is
>>     not at the tip of one of your branches.  The most obvious
>>     example is to check out the commit at a tagged official release
>>     point, like this:
>>
>>     ------------
>>     $ git checkout v2.6.18
>>     ------------
>>
>>     Earlier versions of git did not allow this and asked you to
>>     create a temporary branch using the `-b` option, but starting from
>>     version 1.5.0, the above command 'detaches' your HEAD from the
>>     current branch and directly points at the commit named by the tag
>>     (`v2.6.18` in the example above).
>>
>> If read carefully (some may argue that it does not need a very careful
>> reading to get it, though), this hints that "detached HEAD" state is a
>> substitute for using a temporary branch, but it may not be strong enough.
>>
>> I thought that a documentation update in this area was already planned?

A "temporary branch" is probably the simplest description, and would make it easier to grasp the concept in plain language for those that are new to Git without glazing over.

Is how it worked pre version 1.5.0 now moot in terms of reference? Probably the first encounter a user might have is when they arrive at a detached HEAD situation and receive the message that prompted Ron Garret to start this thread. The concept of an automatic temporary branch might be easier to understand from the outset without needing reference to the "old ways" ;)

As an aside, I believe a common misconception is for a user to think they are checking out a single file revision which could be the most likely mechanism to lead them into an inadvertent detached HEAD state. Any improvement in both the first line message and the full documentation would be most helpful.

>
> Jay Soffian (added to CC) agreed to augment the documentation with the
> comprehensive explanation he posted to the list lately.
>
That is good news indeed.
Steve
Previous: Jay Soffian
Message 24 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.