git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Submodule "git branch" says (HEAD detached at <incorrect-commit>)
@ 2019-07-03  8:28 Julius Smith
  2019-07-03  8:31 ` Julius Smith
  2019-07-03 18:17 ` Junio C Hamano
  0 siblings, 2 replies; 4+ messages in thread
From: Julius Smith @ 2019-07-03  8:28 UTC (permalink / raw)
  To: git

Greetings,

I have a repo with two branches A and B, say, and a submodule pointing
to a repo also with two branches, say C and D.  Branch A of the parent
uses branch C of the submodule, while B uses D.  My clone is in a
state (that I've seen often) where branch A's submodule directory
_appears_ to be using a commit for D when really it's a commit for C.
"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?

Thanks,
- Julius

-- 
Julius O. Smith III <jos@ccrma.stanford.edu>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Submodule "git branch" says (HEAD detached at <incorrect-commit>)
  2019-07-03  8:28 Submodule "git branch" says (HEAD detached at <incorrect-commit>) Julius Smith
@ 2019-07-03  8:31 ` Julius Smith
  2019-07-03 18:17 ` Junio C Hamano
  1 sibling, 0 replies; 4+ messages in thread
From: Julius Smith @ 2019-07-03  8:31 UTC (permalink / raw)
  To: git

I should add:
> git --version
git version 2.20.1 (Apple Git-117)

On Wed, Jul 3, 2019 at 1:28 AM Julius Smith <jos@ccrma.stanford.edu> wrote:
>
> Greetings,
>
> I have a repo with two branches A and B, say, and a submodule pointing
> to a repo also with two branches, say C and D.  Branch A of the parent
> uses branch C of the submodule, while B uses D.  My clone is in a
> state (that I've seen often) where branch A's submodule directory
> _appears_ to be using a commit for D when really it's a commit for C.
> "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?
>
> Thanks,
> - Julius
>
> --
> Julius O. Smith III <jos@ccrma.stanford.edu>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Submodule "git branch" says (HEAD detached at <incorrect-commit>)
  2019-07-03  8:28 Submodule "git branch" says (HEAD detached at <incorrect-commit>) Julius Smith
  2019-07-03  8:31 ` Julius Smith
@ 2019-07-03 18:17 ` Junio C Hamano
  2019-07-03 19:00   ` Julius Smith
  1 sibling, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2019-07-03 18:17 UTC (permalink / raw)
  To: Julius Smith; +Cc: git

Julius Smith <jos@ccrma.stanford.edu> writes:

> "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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Submodule "git branch" says (HEAD detached at <incorrect-commit>)
  2019-07-03 18:17 ` Junio C Hamano
@ 2019-07-03 19:00   ` Julius Smith
  0 siblings, 0 replies; 4+ messages in thread
From: Julius Smith @ 2019-07-03 19:00 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Thanks for the explanation.  So then to find out the current commit of
the submodule, I should cd into the submodule directory and say "git
rev-parse HEAD" or "git log -n1", etc.

Suggestion: for a moved HEAD, it would be nice to show "(detached from
<original-commit> now at <current-commit>)".

Thanks for considering, and thanks for a truly great software tool.

- Julius

On Wed, Jul 3, 2019 at 11:17 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> Julius Smith <jos@ccrma.stanford.edu> writes:
>
> > "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.
>
>


-- 

Julius O. Smith III <jos@ccrma.stanford.edu>
Professor of Music and, by courtesy, Electrical Engineering
CCRMA, Stanford University
http://ccrma.stanford.edu/~jos/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-07-03 19:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-03  8:28 Submodule "git branch" says (HEAD detached at <incorrect-commit>) Julius Smith
2019-07-03  8:31 ` Julius Smith
2019-07-03 18:17 ` Junio C Hamano
2019-07-03 19:00   ` Julius Smith

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).