{"thread":{"id":"50403","subject":"[BUG]: git checkout on a new tag with current HEAD shows \"head detached\" at previous tag","startedAt":"2019-02-05T09:19:58Z","lastAt":"2019-02-05T15:23:13Z","messageCount":4,"participants":["Dani Koretsky","Randall S. Becker","Ævar Arnfjörð Bjarmason"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"368513","messageId":"CANcfovV3Pq3pubtNq4HCSZOJ5OC9dVSm+19VkOiQimAH+fttYw@mail.gmail.com","threadId":"50403","inReplyTo":null,"subject":"[BUG]: git checkout on a new tag with current HEAD shows \"head detached\" at previous tag","fromName":"Dani Koretsky","fromEmail":"dani@cybereason.com","sentAt":"2019-02-05T09:19:40Z","receivedAt":"2019-02-05T09:19:58Z","isPatch":false,"sender":{"key":"dani@cybereason.com","avatar":null},"body":"I have 2 tags such as release-17.6.230 and release-17.6.220:\nIf I'm changing commits, all works as expected.\n\nIf however both are pointing to the same commit, the output is as follows:\n\ngit checkout release-17.6.220\ngit status\nHEAD detached at release-17.6.220\n\nnow if I run:\ngit checkout release-17.6.230\ngit status\nHEAD detached at release-17.6.220\n\nWhich is theoretically correct, but I'd expect after checking out a\ncertain tag I'd be see that specific tag...\n\nSorry if this is intended behavior, I couldn't find clear mention of\nthis behavior on the git checkout documentation online..\n\nLet me know if I can help in anyway.\n\nCheers,\nDani Koretsky - Researcher\n"},{"id":"368524","messageId":"000c01d4bd63$c8fc7ff0$5af57fd0$@nexbridge.com","threadId":"50403","inReplyTo":"CANcfovV3Pq3pubtNq4HCSZOJ5OC9dVSm+19VkOiQimAH+fttYw@mail.gmail.com","subject":"RE: [BUG]: git checkout on a new tag with current HEAD shows \"head detached\" at previous tag","fromName":"Randall S. Becker","fromEmail":"rsbecker@nexbridge.com","sentAt":"2019-02-05T15:02:09Z","receivedAt":"2019-02-05T15:02:30Z","isPatch":false,"sender":{"key":"randall.becker@nexbridge.ca","avatar":"https://avatars.githubusercontent.com/u/28956764?v=4"},"body":"On February 5, 2019 4:20, Dani Koretsky wrote:\n> I have 2 tags such as release-17.6.230 and release-17.6.220:\n> If I'm changing commits, all works as expected.\n> \n> If however both are pointing to the same commit, the output is as follows:\n> \n> git checkout release-17.6.220\n> git status\n> HEAD detached at release-17.6.220\n> \n> now if I run:\n> git checkout release-17.6.230\n> git status\n> HEAD detached at release-17.6.220\n> \n> Which is theoretically correct, but I'd expect after checking out a certain tag\n> I'd be see that specific tag...\n> \n> Sorry if this is intended behavior, I couldn't find clear mention of this\n> behavior on the git checkout documentation online..\n\nPlease use\n\ngit checkout -b release-17.6.220\n\nWhat your  commands above have done is resolved release-17.6.220 to a commit, then checked out that commit instead of creating a branch. Alternatively, use\n\ngit checkout -b new-branch release-17.6.220\n\nto name it something else.\n\nRegards,\nRandall\n\n-- Brief whoami:\n NonStop developer since approximately 211288444200000000\n UNIX developer since approximately 421664400\n-- In my real life, I talk too much.\n\n\n\n"},{"id":"368525","messageId":"87munal0zb.fsf@evledraar.gmail.com","threadId":"50403","inReplyTo":"CANcfovV3Pq3pubtNq4HCSZOJ5OC9dVSm+19VkOiQimAH+fttYw@mail.gmail.com","subject":"Re: [BUG]: git checkout on a new tag with current HEAD shows \"head detached\" at previous tag","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2019-02-05T15:16:24Z","receivedAt":"2019-02-05T15:16:30Z","isPatch":false,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Tue, Feb 05 2019, Dani Koretsky wrote:\n\n> I have 2 tags such as release-17.6.230 and release-17.6.220:\n> If I'm changing commits, all works as expected.\n>\n> If however both are pointing to the same commit, the output is as follows:\n>\n> git checkout release-17.6.220\n> git status\n> HEAD detached at release-17.6.220\n>\n> now if I run:\n> git checkout release-17.6.230\n> git status\n> HEAD detached at release-17.6.220\n>\n> Which is theoretically correct, but I'd expect after checking out a\n> certain tag I'd be see that specific tag...\n>\n> Sorry if this is intended behavior, I couldn't find clear mention of\n> this behavior on the git checkout documentation online..\n>\n> Let me know if I can help in anyway.\n\nYou're right about this issue. I haven't dug deep into this, but just\nenough to see why this is. When we \"git checkout\" something we write to\nthe reflog that we moved to such-and-such a ref, we then consult the\nreflog when you run \"git status\" to see what we detached the HEAD from.\n\nAs you can see if you run \"git reflog\" after you check out the first and\nsecond tag, that entry doesn't change, and we still note just the first\ntag you checked out.\n\nThis is going to be because of a short-circuit behavior where we see \"oh\nwe already checked this out\".\n\nMaybe that needs to be fixed as a bug, but would have more implications,\ni.e. are there cases where you can flip-flop and end up spamming the\nreflog, should the post-checkout hook run or not in those cases, etc.\n"},{"id":"368526","messageId":"87lg2ul0o3.fsf@evledraar.gmail.com","threadId":"50403","inReplyTo":"87munal0zb.fsf@evledraar.gmail.com","subject":"Re: [BUG]: git checkout on a new tag with current HEAD shows \"head detached\" at previous tag","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2019-02-05T15:23:08Z","receivedAt":"2019-02-05T15:23:13Z","isPatch":false,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Tue, Feb 05 2019, Ævar Arnfjörð Bjarmason wrote:\n\n> On Tue, Feb 05 2019, Dani Koretsky wrote:\n>\n>> I have 2 tags such as release-17.6.230 and release-17.6.220:\n>> If I'm changing commits, all works as expected.\n>>\n>> If however both are pointing to the same commit, the output is as follows:\n>>\n>> git checkout release-17.6.220\n>> git status\n>> HEAD detached at release-17.6.220\n>>\n>> now if I run:\n>> git checkout release-17.6.230\n>> git status\n>> HEAD detached at release-17.6.220\n>>\n>> Which is theoretically correct, but I'd expect after checking out a\n>> certain tag I'd be see that specific tag...\n>>\n>> Sorry if this is intended behavior, I couldn't find clear mention of\n>> this behavior on the git checkout documentation online..\n>>\n>> Let me know if I can help in anyway.\n>\n> You're right about this issue. I haven't dug deep into this, but just\n> enough to see why this is. When we \"git checkout\" something we write to\n> the reflog that we moved to such-and-such a ref, we then consult the\n> reflog when you run \"git status\" to see what we detached the HEAD from.\n>\n> As you can see if you run \"git reflog\" after you check out the first and\n> second tag, that entry doesn't change, and we still note just the first\n> tag you checked out.\n>\n> This is going to be because of a short-circuit behavior where we see \"oh\n> we already checked this out\".\n>\n> Maybe that needs to be fixed as a bug, but would have more implications,\n> i.e. are there cases where you can flip-flop and end up spamming the\n> reflog, should the post-checkout hook run or not in those cases, etc.\n\nTo add to this: I think there's a good case to be made that this is\ndefinitely *not* a bug, and changing it would be introducing a bug.\n\nIt's 100% true that the \"HEAD was detached at\" the first first tag to be\nchecked out, the subsequent \"git checkout [other tag]\" was a noop.\n"}]}