{"thread":{"id":"51422","subject":"Submodule \"git branch\" says (HEAD detached at <incorrect-commit>)","startedAt":"2019-07-03T08:29:37Z","lastAt":"2019-07-03T19:01:28Z","messageCount":4,"participants":["Julius Smith","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"378527","messageId":"CAMPRpjUWBXCEagDB5RwsBTYSJWeypOeY47CGWOO95oZiSCTOjw@mail.gmail.com","threadId":"51422","inReplyTo":null,"subject":"Submodule \"git branch\" says (HEAD detached at <incorrect-commit>)","fromName":"Julius Smith","fromEmail":"jos@ccrma.stanford.edu","sentAt":"2019-07-03T08:28:59Z","receivedAt":"2019-07-03T08:29:37Z","isPatch":false,"sender":{"key":"jos@ccrma.stanford.edu","avatar":"https://gravatar.com/avatar/30f98fd10591be7b7108880f894d4f37f0d9cf3ca5ab18235386c923a20ee8cf?d=mp&s=160"},"body":"Greetings,\n\nI have a repo with two branches A and B, say, and a submodule pointing\nto a repo also with two branches, say C and D.  Branch A of the parent\nuses branch C of the submodule, while B uses D.  My clone is in a\nstate (that I've seen often) where branch A's submodule directory\n_appears_ to be using a commit for D when really it's a commit for C.\n\"git branch\" in the the submodule directory says \"(detached from\n<commit-for-D>)\" but this seems to be wrong.  I did \"git diff\n<commit>\" in the submodule directory to show that it was the C-commit\nand not the D-commit as it appeared.  Could \"git branch\" in the\nsubmodule directory be referring to the commit at the time it was\nfirst detached and not updating after a \"git submodule update --init\"\nin the parent?\n\nThanks,\n- Julius\n\n-- \nJulius O. Smith III <jos@ccrma.stanford.edu>\n"},{"id":"378528","messageId":"CAMPRpjUAKPo-fFeE1R_QjMTrc_RST0y-1Jrhcg2Z-xyH7ubt5A@mail.gmail.com","threadId":"51422","inReplyTo":"CAMPRpjUWBXCEagDB5RwsBTYSJWeypOeY47CGWOO95oZiSCTOjw@mail.gmail.com","subject":"Re: Submodule \"git branch\" says (HEAD detached at <incorrect-commit>)","fromName":"Julius Smith","fromEmail":"jos@ccrma.stanford.edu","sentAt":"2019-07-03T08:31:40Z","receivedAt":"2019-07-03T08:32:18Z","isPatch":false,"sender":{"key":"jos@ccrma.stanford.edu","avatar":"https://gravatar.com/avatar/30f98fd10591be7b7108880f894d4f37f0d9cf3ca5ab18235386c923a20ee8cf?d=mp&s=160"},"body":"I should add:\n> git --version\ngit version 2.20.1 (Apple Git-117)\n\nOn Wed, Jul 3, 2019 at 1:28 AM Julius Smith <jos@ccrma.stanford.edu> wrote:\n>\n> Greetings,\n>\n> I have a repo with two branches A and B, say, and a submodule pointing\n> to a repo also with two branches, say C and D.  Branch A of the parent\n> uses branch C of the submodule, while B uses D.  My clone is in a\n> state (that I've seen often) where branch A's submodule directory\n> _appears_ to be using a commit for D when really it's a commit for C.\n> \"git branch\" in the the submodule directory says \"(detached from\n> <commit-for-D>)\" but this seems to be wrong.  I did \"git diff\n> <commit>\" in the submodule directory to show that it was the C-commit\n> and not the D-commit as it appeared.  Could \"git branch\" in the\n> submodule directory be referring to the commit at the time it was\n> first detached and not updating after a \"git submodule update --init\"\n> in the parent?\n>\n> Thanks,\n> - Julius\n>\n> --\n> Julius O. Smith III <jos@ccrma.stanford.edu>\n"},{"id":"378560","messageId":"xmqq7e8z0ypm.fsf@gitster-ct.c.googlers.com","threadId":"51422","inReplyTo":"CAMPRpjUWBXCEagDB5RwsBTYSJWeypOeY47CGWOO95oZiSCTOjw@mail.gmail.com","subject":"Re: Submodule \"git branch\" says (HEAD detached at <incorrect-commit>)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-07-03T18:17:41Z","receivedAt":"2019-07-03T18:17:46Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Julius Smith <jos@ccrma.stanford.edu> writes:\n\n> \"git branch\" in the the submodule directory says \"(detached from\n> <commit-for-D>)\" but this seems to be wrong.  I did \"git diff\n> <commit>\" in the submodule directory to show that it was the C-commit\n> and not the D-commit as it appeared.  Could \"git branch\" in the\n> submodule directory be referring to the commit at the time it was\n> first detached and not updating after a \"git submodule update --init\"\n> in the parent?\n\nThere are \"detached from\" and \"detached at\" messages.  Their use was\nsomewhat inconsistent in the older version of Git, but at least\nsince 2.4.0 (quoting from Documentation/RelNotes/2.4.0.txt):\n\n * The phrasing \"git branch\" uses to describe a detached HEAD has been\n   updated to agree with the phrasing used by \"git status\":\n\n    - When HEAD is at the same commit as when it was originally\n      detached, they now both show \"detached at <commit object name>\".\n\n    - When HEAD has moved since it was originally detached, they now\n      both show \"detached from <commit object name>\".\n\n   Previously, \"git branch\" always used \"from\".\n\n\"git branch\" and \"git status\" should be using the same language to\ndescribe the situation.\n"},{"id":"378567","messageId":"CAMPRpjULRpzG+Xf8Ezc2+-4cVB7phGs9h+7nxhx-GP44__mfeg@mail.gmail.com","threadId":"51422","inReplyTo":"xmqq7e8z0ypm.fsf@gitster-ct.c.googlers.com","subject":"Re: Submodule \"git branch\" says (HEAD detached at <incorrect-commit>)","fromName":"Julius Smith","fromEmail":"jos@ccrma.stanford.edu","sentAt":"2019-07-03T19:00:49Z","receivedAt":"2019-07-03T19:01:28Z","isPatch":false,"sender":{"key":"jos@ccrma.stanford.edu","avatar":"https://gravatar.com/avatar/30f98fd10591be7b7108880f894d4f37f0d9cf3ca5ab18235386c923a20ee8cf?d=mp&s=160"},"body":"Thanks for the explanation.  So then to find out the current commit of\nthe submodule, I should cd into the submodule directory and say \"git\nrev-parse HEAD\" or \"git log -n1\", etc.\n\nSuggestion: for a moved HEAD, it would be nice to show \"(detached from\n<original-commit> now at <current-commit>)\".\n\nThanks for considering, and thanks for a truly great software tool.\n\n- Julius\n\nOn Wed, Jul 3, 2019 at 11:17 AM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Julius Smith <jos@ccrma.stanford.edu> writes:\n>\n> > \"git branch\" in the the submodule directory says \"(detached from\n> > <commit-for-D>)\" but this seems to be wrong.  I did \"git diff\n> > <commit>\" in the submodule directory to show that it was the C-commit\n> > and not the D-commit as it appeared.  Could \"git branch\" in the\n> > submodule directory be referring to the commit at the time it was\n> > first detached and not updating after a \"git submodule update --init\"\n> > in the parent?\n>\n> There are \"detached from\" and \"detached at\" messages.  Their use was\n> somewhat inconsistent in the older version of Git, but at least\n> since 2.4.0 (quoting from Documentation/RelNotes/2.4.0.txt):\n>\n>  * The phrasing \"git branch\" uses to describe a detached HEAD has been\n>    updated to agree with the phrasing used by \"git status\":\n>\n>     - When HEAD is at the same commit as when it was originally\n>       detached, they now both show \"detached at <commit object name>\".\n>\n>     - When HEAD has moved since it was originally detached, they now\n>       both show \"detached from <commit object name>\".\n>\n>    Previously, \"git branch\" always used \"from\".\n>\n> \"git branch\" and \"git status\" should be using the same language to\n> describe the situation.\n>\n>\n\n\n-- \n\nJulius O. Smith III <jos@ccrma.stanford.edu>\nProfessor of Music and, by courtesy, Electrical Engineering\nCCRMA, Stanford University\nhttp://ccrma.stanford.edu/~jos/\n"}]}