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

Re: detached HEAD before root commit - possible?

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 24, 2013, 05:01 UTC
Message-ID
<7vbo6wdrvl.fsf@alter.siamese.dyndns.org>
In-Reply-To
<CANiSa6jNjCDjj_ZD7COXyDUx9DxFpuVqT-Lm24KQVMDK=serpw@mail.gmail.com>
Martin von Zweigbergk <martinvonz@gmail.com> writes:
Show 8 quoted lines
> On Sun, Jun 23, 2013 at 4:54 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
>>
>> In other words, HEAD always either points to an unborn or existing
>> branch or an existing commit.  It's not clear to me what it would
>> mean to detach from an unborn branch.
>
> I think it should mean that the next commit would be a root commit (of
> course) and that HEAD would be detached and point to that commit.
Yup.  As Jonathan outlined how the current system works:
 - $GIT_DIR/HEAD could be a symref to a branch, which may or may not
   exist (the latter being "unborn"); or
 - $GIT_DIR/HEAD could be directly pointing at an existing commit,
   which is the definition of "detached", as you "detach HEAD at
   that commit".

even though such a "I do not have any commit and I will not be on any branch" state were to be supported, the consequence of that would be that a natural implementation of such a state is to represent it by not having $GIT_DIR/HEAD at all. That will break quite a lot of things, as such a directory $GIT_DIR will not be treated as a git directory in the first place. Of course, you could fix them up to support it, but I doubt if it is worth the trouble.

Previous: Martin von ZweigbergkNext: Matthieu Moy
Message 4 of 5 in “detached HEAD before root commit - possible?”
  1. SZEDER GáborJun 23, 2013
  2. Jonathan NiederJun 23, 2013
  3. Martin von ZweigbergkJun 24, 2013
  4. Junio C HamanoJun 24, 2013
  5. Matthieu MoyJun 24, 2013

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.