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

Re: Submodule "git branch" says (HEAD detached at <incorrect-commit>)

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 3, 2019, 18:17 UTC
Message-ID
<xmqq7e8z0ypm.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<CAMPRpjUWBXCEagDB5RwsBTYSJWeypOeY47CGWOO95oZiSCTOjw@mail.gmail.com>
Julius Smith <jos@ccrma.stanford.edu> writes:
Show 7 quoted lines
> "git branch" in the the submodule directory says "(detached from
> <commit-for-D>)" but this seems to be wrong.  I did "git diff
> <commit>" in the submodule directory to show that it was the C-commit
> and not the D-commit as it appeared.  Could "git branch" in the
> submodule directory be referring to the commit at the time it was
> first detached and not updating after a "git submodule update --init"
> in the parent?

There are "detached from" and "detached at" messages. Their use was somewhat inconsistent in the older version of Git, but at least since 2.4.0 (quoting from Documentation/RelNotes/2.4.0.txt):

 * The phrasing "git branch" uses to describe a detached HEAD has been
   updated to agree with the phrasing used by "git status":
    - When HEAD is at the same commit as when it was originally
      detached, they now both show "detached at <commit object name>".
    - When HEAD has moved since it was originally detached, they now
      both show "detached from <commit object name>".
   Previously, "git branch" always used "from".

"git branch" and "git status" should be using the same language to describe the situation.

Previous: Julius SmithNext: Julius Smith
Message 3 of 4 in “Submodule "git branch" says (HEAD detached at <incorrect-commit>)”
  1. Julius SmithJul 3, 2019
  2. Julius SmithJul 3, 2019
  3. Junio C HamanoJul 3, 2019
  4. Julius SmithJul 3, 2019

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.