{"thread":{"id":"52459","subject":"Head, Branch != Head -> Branch?","startedAt":"2019-12-14T18:00:08Z","lastAt":"2019-12-15T05:36:16Z","messageCount":5,"participants":["Tomas Zubiri","mattr94@gmail.com","Joshua Teves"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"388212","messageId":"CAE3VKEpPye+GyR7Uo9WBa=1i1L=dFq9AHfdNnhiw19K-jWLtBA@mail.gmail.com","threadId":"52459","inReplyTo":null,"subject":"Head, Branch != Head -> Branch?","fromName":"Tomas Zubiri","fromEmail":"me@tomaszubiri.com","sentAt":"2019-12-14T18:00:01Z","receivedAt":"2019-12-14T18:00:08Z","isPatch":false,"sender":{"key":"me@tomaszubiri.com","avatar":null},"body":"Hello, I'm writing because I believe I found a case where git could be\nsimplified. I'm posting my terminal log so that you can see exactly\nwhat I saw. Comments are marked with >> . Important spanish git was\ntranslated.\n\n(base) tomas@toms:~/Projects/tomaszubiri.com/site$ git status\nHEAD detached at 54da1ac\nCambios no rastreados para el commit:\n  (usa \"git add <archivo>...\" para actualizar lo que será confirmado)\n  (usa \"git checkout -- <archivo>...\" para descartar los cambios en el\ndirectorio de trabajo)\n\nmodificado:     cv/en/index.html\nmodificado:     cv/index.html\n\nsin cambios agregados al commit (usa \"git add\" y/o \"git commit -a\")\n(base) tomas@toms:~/Projects/tomaszubiri.com/site$ git add cv/en/index.html\n(base) tomas@toms:~/Projects/tomaszubiri.com/site$ git add cv/index.html\n(base) tomas@toms:~/Projects/tomaszubiri.com/site$ git commit -m\n\"Agrego mi celular, por favor no me manden spam\"\n[HEAD detached 82b2b55] Agrego mi celular, por favor no me manden spam\n 2 files changed, 3 insertions(+), 1 deletion(-)\n(base) tomas@toms:~/Projects/tomaszubiri.com/site$ git push\nfatal: Actualmente no estás en una rama.\nPara hacer un push a la historia que lleva al estado actual\n(HEAD detached), use\n\ngit push origin HEAD:<nombre-de-rama-remota>\n\n(base) tomas@toms:~/Projects/tomaszubiri.com/site$ git push origin ^C\n(base) tomas@toms:~/Projects/tomaszubiri.com/site$ git log\ncommit 82b2b55b3f7768a60e3d8bcda97d4d623ff0e044 (HEAD)\nAuthor: Tomas Zubiri <me@tomaszubiri.com>\nDate:   Fri Dec 13 21:37:30 2019 -0300\n\n    Agrego mi celular, por favor no me manden spam\n>> This is the commit I wanted to push\n\ncommit 54da1ac07a5c7c2e7234911a0af76aee042b5b99\nAuthor: Tomas Zubiri <me@tomaszubiri.com>\nDate:   Fri Dec 13 20:33:11 2019 -0300\n\n    Limpio url para cv en inglés.\n>> This is an abandoned commit I didn't push.\n\n\n\ncommit 81542e725149ba5da36560ad14d4871eb7ea01e6 (origin/master)\nAuthor: Tomas Zubiri <me@tomaszubiri.com>\nDate:   Fri Oct 18 17:08:50 2019 -0300\n\n    especifico tecnologías de contribución de codigo\n>> This is what's in production\n\n\n(base) tomas@toms:~/Projects/tomaszubiri.com/site$ git checkout origin/master^C\n>> ^C cancels the command, I notice there's an extra commit.\n\n(base) tomas@toms:~/Projects/tomaszubiri.com/site$ git branch newmaster\n(base) tomas@toms:~/Projects/tomaszubiri.com/site$ git checkout origin/master\nLa posición previa de HEAD era 82b2b55 Agrego mi celular, por favor no\nme manden spam\n>> Previous head position was..\n\nHEAD está ahora en 81542e7 especifico tecnologías de contribución de codigo\n(base) tomas@toms:~/Projects/tomaszubiri.com/site$ git cherry-pick newmaster\n[HEAD desacoplado 912c91a] Agrego mi celular, por favor no me manden spam\n Date: Fri Dec 13 21:37:30 2019 -0300\n 2 files changed, 3 insertions(+), 1 deletion(-)\n(base) tomas@toms:~/Projects/tomaszubiri.com/site$ git log\ncommit 912c91a92e17de33247e2040d1dd01adbfc218eb (HEAD)\nAuthor: Tomas Zubiri <me@tomaszubiri.com>\nDate:   Fri Dec 13 21:37:30 2019 -0300\n\n    Agrego mi celular, por favor no me manden spam\n\ncommit 81542e725149ba5da36560ad14d4871eb7ea01e6 (origin/master)\nAuthor: Tomas Zubiri <me@tomaszubiri.com>\nDate:   Fri Oct 18 17:08:50 2019 -0300\n\n    especifico tecnologías de contribución de codigo\n>> Looks good.\n\n(base) tomas@toms:~/Projects/tomaszubiri.com/site$ git branch master\nfatal: Una rama llamada 'master' ya existe.\n(base) tomas@toms:~/Projects/tomaszubiri.com/site$ git branch -D master\nEliminada la rama master (era 679eaf3)..\n(base) tomas@toms:~/Projects/tomaszubiri.com/site$ git branch master\n(base) tomas@toms:~/Projects/tomaszubiri.com/site$ git push^C\n>> Gotta double check.\n\n(base) tomas@toms:~/Projects/tomaszubiri.com/site$ git log\ncommit 912c91a92e17de33247e2040d1dd01adbfc218eb (HEAD, master)\nAuthor: Tomas Zubiri <me@tomaszubiri.com>\nDate:   Fri Dec 13 21:37:30 2019 -0300\n\n    Agrego mi celular, por favor no me manden spam\n\ncommit 81542e725149ba5da36560ad14d4871eb7ea01e6 (origin/master)\nAuthor: Tomas Zubiri <me@tomaszubiri.com>\nDate:   Fri Oct 18 17:08:50 2019 -0300\n\n    especifico tecnologías de contribución de codigo\n\n\n(base) tomas@toms:~/Projects/tomaszubiri.com/site$ git push\nfatal: Actualmente no estás en una rama.\n>> Fatal: You are not currently on a branch.\n\nPara hacer un push a la historia que lleva al estado actual\n(HEAD desacoplado), use\n\ngit push origin HEAD:<nombre-de-rama-remota>\n\n(base) tomas@toms:~/Projects/tomaszubiri.com/site$ git push origin/master\nfatal: Actualmente no estás en una rama.\nPara hacer un push a la historia que lleva al estado actual\n(HEAD desacoplado), use\n\ngit push origin/master HEAD:<nombre-de-rama-remota>\n\n(base) tomas@toms:~/Projects/tomaszubiri.com/site$ git push ^Cigin/master\n(base) tomas@toms:~/Projects/tomaszubiri.com/site$ git log\ncommit 912c91a92e17de33247e2040d1dd01adbfc218eb (HEAD, master)\nAuthor: Tomas Zubiri <me@tomaszubiri.com>\nDate:   Fri Dec 13 21:37:30 2019 -0300\n\n    Agrego mi celular, por favor no me manden spam\n\ncommit 81542e725149ba5da36560ad14d4871eb7ea01e6 (origin/master)\nAuthor: Tomas Zubiri <me@tomaszubiri.com>\nDate:   Fri Oct 18 17:08:50 2019 -0300\n\n    especifico tecnologías de contribución de codigo\n\n(base) tomas@toms:~/Projects/tomaszubiri.com/site$ git push >> So\nconfused I repeated a command.\nfatal: Actualmente no estás en una rama.\nPara hacer un push a la historia que lleva al estado actual\n(HEAD desacoplado), use\n\ngit push origin HEAD:<nombre-de-rama-remota>\n\n(base) tomas@toms:~/Projects/tomaszubiri.com/site$ git log\ncommit 912c91a92e17de33247e2040d1dd01adbfc218eb (HEAD, master)\nAuthor: Tomas Zubiri <me@tomaszubiri.com>\nDate:   Fri Dec 13 21:37:30 2019 -0300\n\n    Agrego mi celular, por favor no me manden spam\n\ncommit 81542e725149ba5da36560ad14d4871eb7ea01e6 (origin/master)\nAuthor: Tomas Zubiri <me@tomaszubiri.com>\nDate:   Fri Oct 18 17:08:50 2019 -0300\n\n    especifico tecnologías de contribución de codigo\n\n\n(base) tomas@toms:~/Projects/tomaszubiri.com/site$ git push\nfatal: Actualmente no estás en una rama.\n>> Fatal: Not currently on a branch\n\nPara hacer un push a la historia que lleva al estado actual\n(HEAD desacoplado), use\n\ngit push origin HEAD:<nombre-de-rama-remota>\n\n(base) tomas@toms:~/Projects/tomaszubiri.com/site$ git checkout master\nCambiado a rama 'master'\n>> Now on 'master' branch\n\n(base) tomas@toms:~/Projects/tomaszubiri.com/site$ git push\nfatal: La rama actual master no tiene una rama upstream.\n>> This error message is something I would expect, since I deleted the master branch and created a new one. That's ok.\n\nPara realizar un push de la rama actual y configurar el remoto como\nupstream, use\n\ngit push --set-upstream origin master\n\n(base) tomas@toms:~/Projects/tomaszubiri.com/site$ git log\ncommit 912c91a92e17de33247e2040d1dd01adbfc218eb (HEAD -> master)\nAuthor: Tomas Zubiri <me@tomaszubiri.com>\nDate:   Fri Dec 13 21:37:30 2019 -0300\n\n    Agrego mi celular, por favor no me manden spam\n\ncommit 81542e725149ba5da36560ad14d4871eb7ea01e6 (origin/master)\nAuthor: Tomas Zubiri <me@tomaszubiri.com>\nDate:   Fri Oct 18 17:08:50 2019 -0300\n\n    especifico tecnologías de contribución de codigo\n\n\nThank you for stepping in my shoes for a moment here. I understand now\nthat Head is a special kind of tag and it must be attached to a\nbranch. But I don't yet understand why the distinction between head\nattached to branch and head and branch in the same commit is\nnecessary. Couple that to the fact that git forgot (perhaps with good\ncause) what remote master pointed to, it feels like this is a place\nwhere git could improve in simplicity.\n\nMy naive suggestion would be as follows:\n\n When HEAD is pointing to a commit and another branch is pointing to\nthe same commit, consider the head attached to that commit.\nI understand that, if there were multiple branches on the same commit,\ngit wouldn't know what remote to push to, so in such case a\ndisambiguation would be needed, but the case here would be that we are\non 2 branches, not none!\n\nWhat am I missing here? Would this change have catastrophic consequences?\n\nRegards.\n"},{"id":"388214","messageId":"CAE3VKEppVv=rocJU7jHKu7i=dLyaHhpauTBmm91udjZ_DOpW+g@mail.gmail.com","threadId":"52459","inReplyTo":"CAE3VKEpPye+GyR7Uo9WBa=1i1L=dFq9AHfdNnhiw19K-jWLtBA@mail.gmail.com","subject":"Re: Head, Branch != Head -> Branch?","fromName":"Tomas Zubiri","fromEmail":"me@tomaszubiri.com","sentAt":"2019-12-14T21:56:55Z","receivedAt":"2019-12-14T21:57:13Z","isPatch":false,"sender":{"key":"me@tomaszubiri.com","avatar":null},"body":"After going through the code and thinking about this. I think the\nunexpected results came from git branch not checking out the branch I\ncreated.\nI know git checkout -b master would have been the result I wanted. If\nI were to create another commit with HEAD checked out instead of\nmaster, master would not update, only HEAD would.\nI guess the real crime here is that git branch does not checkout the\nbranch created. I don't think I ever wanted to create a branch without\nchecking it out, otherwise I would use git tag.\n\nTomas Zubiri\nSoftware Developer\nCel: +54 911 5891 8239\n\n\nEl sáb., 14 de dic. de 2019 a la(s) 15:00, Tomas Zubiri\n(me@tomaszubiri.com) escribió:\n>\n> Hello, I'm writing because I believe I found a case where git could be\n> simplified. I'm posting my terminal log so that you can see exactly\n> what I saw. Comments are marked with >> . Important spanish git was\n> translated.\n>\n> (base) tomas@toms:~/Projects/tomaszubiri.com/site$ git status\n> HEAD detached at 54da1ac\n> Cambios no rastreados para el commit:\n>   (usa \"git add <archivo>...\" para actualizar lo que será confirmado)\n>   (usa \"git checkout -- <archivo>...\" para descartar los cambios en el\n> directorio de trabajo)\n>\n> modificado:     cv/en/index.html\n> modificado:     cv/index.html\n>\n> sin cambios agregados al commit (usa \"git add\" y/o \"git commit -a\")\n> (base) tomas@toms:~/Projects/tomaszubiri.com/site$ git add cv/en/index.html\n> (base) tomas@toms:~/Projects/tomaszubiri.com/site$ git add cv/index.html\n> (base) tomas@toms:~/Projects/tomaszubiri.com/site$ git commit -m\n> \"Agrego mi celular, por favor no me manden spam\"\n> [HEAD detached 82b2b55] Agrego mi celular, por favor no me manden spam\n>  2 files changed, 3 insertions(+), 1 deletion(-)\n> (base) tomas@toms:~/Projects/tomaszubiri.com/site$ git push\n> fatal: Actualmente no estás en una rama.\n> Para hacer un push a la historia que lleva al estado actual\n> (HEAD detached), use\n>\n> git push origin HEAD:<nombre-de-rama-remota>\n>\n> (base) tomas@toms:~/Projects/tomaszubiri.com/site$ git push origin ^C\n> (base) tomas@toms:~/Projects/tomaszubiri.com/site$ git log\n> commit 82b2b55b3f7768a60e3d8bcda97d4d623ff0e044 (HEAD)\n> Author: Tomas Zubiri <me@tomaszubiri.com>\n> Date:   Fri Dec 13 21:37:30 2019 -0300\n>\n>     Agrego mi celular, por favor no me manden spam\n> >> This is the commit I wanted to push\n>\n> commit 54da1ac07a5c7c2e7234911a0af76aee042b5b99\n> Author: Tomas Zubiri <me@tomaszubiri.com>\n> Date:   Fri Dec 13 20:33:11 2019 -0300\n>\n>     Limpio url para cv en inglés.\n> >> This is an abandoned commit I didn't push.\n>\n>\n>\n> commit 81542e725149ba5da36560ad14d4871eb7ea01e6 (origin/master)\n> Author: Tomas Zubiri <me@tomaszubiri.com>\n> Date:   Fri Oct 18 17:08:50 2019 -0300\n>\n>     especifico tecnologías de contribución de codigo\n> >> This is what's in production\n>\n>\n> (base) tomas@toms:~/Projects/tomaszubiri.com/site$ git checkout origin/master^C\n> >> ^C cancels the command, I notice there's an extra commit.\n>\n> (base) tomas@toms:~/Projects/tomaszubiri.com/site$ git branch newmaster\n> (base) tomas@toms:~/Projects/tomaszubiri.com/site$ git checkout origin/master\n> La posición previa de HEAD era 82b2b55 Agrego mi celular, por favor no\n> me manden spam\n> >> Previous head position was..\n>\n> HEAD está ahora en 81542e7 especifico tecnologías de contribución de codigo\n> (base) tomas@toms:~/Projects/tomaszubiri.com/site$ git cherry-pick newmaster\n> [HEAD desacoplado 912c91a] Agrego mi celular, por favor no me manden spam\n>  Date: Fri Dec 13 21:37:30 2019 -0300\n>  2 files changed, 3 insertions(+), 1 deletion(-)\n> (base) tomas@toms:~/Projects/tomaszubiri.com/site$ git log\n> commit 912c91a92e17de33247e2040d1dd01adbfc218eb (HEAD)\n> Author: Tomas Zubiri <me@tomaszubiri.com>\n> Date:   Fri Dec 13 21:37:30 2019 -0300\n>\n>     Agrego mi celular, por favor no me manden spam\n>\n> commit 81542e725149ba5da36560ad14d4871eb7ea01e6 (origin/master)\n> Author: Tomas Zubiri <me@tomaszubiri.com>\n> Date:   Fri Oct 18 17:08:50 2019 -0300\n>\n>     especifico tecnologías de contribución de codigo\n> >> Looks good.\n>\n> (base) tomas@toms:~/Projects/tomaszubiri.com/site$ git branch master\n> fatal: Una rama llamada 'master' ya existe.\n> (base) tomas@toms:~/Projects/tomaszubiri.com/site$ git branch -D master\n> Eliminada la rama master (era 679eaf3)..\n> (base) tomas@toms:~/Projects/tomaszubiri.com/site$ git branch master\n> (base) tomas@toms:~/Projects/tomaszubiri.com/site$ git push^C\n> >> Gotta double check.\n>\n> (base) tomas@toms:~/Projects/tomaszubiri.com/site$ git log\n> commit 912c91a92e17de33247e2040d1dd01adbfc218eb (HEAD, master)\n> Author: Tomas Zubiri <me@tomaszubiri.com>\n> Date:   Fri Dec 13 21:37:30 2019 -0300\n>\n>     Agrego mi celular, por favor no me manden spam\n>\n> commit 81542e725149ba5da36560ad14d4871eb7ea01e6 (origin/master)\n> Author: Tomas Zubiri <me@tomaszubiri.com>\n> Date:   Fri Oct 18 17:08:50 2019 -0300\n>\n>     especifico tecnologías de contribución de codigo\n>\n>\n> (base) tomas@toms:~/Projects/tomaszubiri.com/site$ git push\n> fatal: Actualmente no estás en una rama.\n> >> Fatal: You are not currently on a branch.\n>\n> Para hacer un push a la historia que lleva al estado actual\n> (HEAD desacoplado), use\n>\n> git push origin HEAD:<nombre-de-rama-remota>\n>\n> (base) tomas@toms:~/Projects/tomaszubiri.com/site$ git push origin/master\n> fatal: Actualmente no estás en una rama.\n> Para hacer un push a la historia que lleva al estado actual\n> (HEAD desacoplado), use\n>\n> git push origin/master HEAD:<nombre-de-rama-remota>\n>\n> (base) tomas@toms:~/Projects/tomaszubiri.com/site$ git push ^Cigin/master\n> (base) tomas@toms:~/Projects/tomaszubiri.com/site$ git log\n> commit 912c91a92e17de33247e2040d1dd01adbfc218eb (HEAD, master)\n> Author: Tomas Zubiri <me@tomaszubiri.com>\n> Date:   Fri Dec 13 21:37:30 2019 -0300\n>\n>     Agrego mi celular, por favor no me manden spam\n>\n> commit 81542e725149ba5da36560ad14d4871eb7ea01e6 (origin/master)\n> Author: Tomas Zubiri <me@tomaszubiri.com>\n> Date:   Fri Oct 18 17:08:50 2019 -0300\n>\n>     especifico tecnologías de contribución de codigo\n>\n> (base) tomas@toms:~/Projects/tomaszubiri.com/site$ git push >> So\n> confused I repeated a command.\n> fatal: Actualmente no estás en una rama.\n> Para hacer un push a la historia que lleva al estado actual\n> (HEAD desacoplado), use\n>\n> git push origin HEAD:<nombre-de-rama-remota>\n>\n> (base) tomas@toms:~/Projects/tomaszubiri.com/site$ git log\n> commit 912c91a92e17de33247e2040d1dd01adbfc218eb (HEAD, master)\n> Author: Tomas Zubiri <me@tomaszubiri.com>\n> Date:   Fri Dec 13 21:37:30 2019 -0300\n>\n>     Agrego mi celular, por favor no me manden spam\n>\n> commit 81542e725149ba5da36560ad14d4871eb7ea01e6 (origin/master)\n> Author: Tomas Zubiri <me@tomaszubiri.com>\n> Date:   Fri Oct 18 17:08:50 2019 -0300\n>\n>     especifico tecnologías de contribución de codigo\n>\n>\n> (base) tomas@toms:~/Projects/tomaszubiri.com/site$ git push\n> fatal: Actualmente no estás en una rama.\n> >> Fatal: Not currently on a branch\n>\n> Para hacer un push a la historia que lleva al estado actual\n> (HEAD desacoplado), use\n>\n> git push origin HEAD:<nombre-de-rama-remota>\n>\n> (base) tomas@toms:~/Projects/tomaszubiri.com/site$ git checkout master\n> Cambiado a rama 'master'\n> >> Now on 'master' branch\n>\n> (base) tomas@toms:~/Projects/tomaszubiri.com/site$ git push\n> fatal: La rama actual master no tiene una rama upstream.\n> >> This error message is something I would expect, since I deleted the master branch and created a new one. That's ok.\n>\n> Para realizar un push de la rama actual y configurar el remoto como\n> upstream, use\n>\n> git push --set-upstream origin master\n>\n> (base) tomas@toms:~/Projects/tomaszubiri.com/site$ git log\n> commit 912c91a92e17de33247e2040d1dd01adbfc218eb (HEAD -> master)\n> Author: Tomas Zubiri <me@tomaszubiri.com>\n> Date:   Fri Dec 13 21:37:30 2019 -0300\n>\n>     Agrego mi celular, por favor no me manden spam\n>\n> commit 81542e725149ba5da36560ad14d4871eb7ea01e6 (origin/master)\n> Author: Tomas Zubiri <me@tomaszubiri.com>\n> Date:   Fri Oct 18 17:08:50 2019 -0300\n>\n>     especifico tecnologías de contribución de codigo\n>\n>\n> Thank you for stepping in my shoes for a moment here. I understand now\n> that Head is a special kind of tag and it must be attached to a\n> branch. But I don't yet understand why the distinction between head\n> attached to branch and head and branch in the same commit is\n> necessary. Couple that to the fact that git forgot (perhaps with good\n> cause) what remote master pointed to, it feels like this is a place\n> where git could improve in simplicity.\n>\n> My naive suggestion would be as follows:\n>\n>  When HEAD is pointing to a commit and another branch is pointing to\n> the same commit, consider the head attached to that commit.\n> I understand that, if there were multiple branches on the same commit,\n> git wouldn't know what remote to push to, so in such case a\n> disambiguation would be needed, but the case here would be that we are\n> on 2 branches, not none!\n>\n> What am I missing here? Would this change have catastrophic consequences?\n>\n> Regards.\n"},{"id":"388215","messageId":"007401d5b2cf$ac787ed0$05697c70$@gmail.com","threadId":"52459","inReplyTo":"CAE3VKEppVv=rocJU7jHKu7i=dLyaHhpauTBmm91udjZ_DOpW+g@mail.gmail.com","subject":"RE: Head, Branch != Head -> Branch?","fromName":"","fromEmail":"mattr94@gmail.com","sentAt":"2019-12-14T22:41:49Z","receivedAt":"2019-12-14T22:42:04Z","isPatch":false,"sender":{"key":"mattr94@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5719846?v=4"},"body":"\nAfter going through the code and thinking about this. I think the unexpected results came from git branch not checking out the branch I created.\nI know git checkout -b master would have been the result I wanted. If I were to create another commit with HEAD checked out instead of master, master would not update, only HEAD would.\n> I guess the real crime here is that git branch does not checkout the branch created. I don't think I ever wanted to create a branch without checking it out, otherwise I would use git tag.\n\nThe problem with this is that git tag doesn't create a new branch, but rather just a new tag so running something like:\n\ngit tag my-tag\ngit checkout my-tag\ngit add .\ngit commit -m \"message\"\n\nwouldn't update my-tag either, you would need to create a new branch for that.  Sometimes I want to create a branch without checking it out, as I'm sure many other users do.  Is it an issue of documentation where maybe the behavior isn't clear? It does specifically say this in the description of git branch, but to be fair it is buried 6 paragraphs in\n\n"},{"id":"388219","messageId":"CAE3VKEozjFXBkQCWQ8FSOPJkwPCM05=eb7jdA4AYwJCtNSH1Ng@mail.gmail.com","threadId":"52459","inReplyTo":"007401d5b2cf$ac787ed0$05697c70$@gmail.com","subject":"Re: Head, Branch != Head -> Branch?","fromName":"Tomas Zubiri","fromEmail":"me@tomaszubiri.com","sentAt":"2019-12-15T03:32:04Z","receivedAt":"2019-12-15T03:32:33Z","isPatch":false,"sender":{"key":"me@tomaszubiri.com","avatar":null},"body":"It was just a combination of an old gripe I have with expecting git\nbranch to checkout and conflating (HEAD pointing to a commit and\nbranch pointing to a commit) with (HEAD pointing to a branch pointing\nto a commit).\n\nIn what scenarios would you create a new branch and not check it out?\nIs there a scenario where you would do this in detached head mode?\n\n---\n\n Could HEAD attach itself to a nearby branch whenever a command\nrequiring an attached branch is called and HEAD points to a commit\nwith only 1 branch attached to it? This would not include commit,\nsince it does not require an attached branch and thus would not fail\non detached mode, this should not break bc because it only affects\ncommands that would otherwise throw an error.\nAlternatively, a more specific error message could be printed,\nprompting the user to attach their head to the branch on the commit.\n\nRegards.\nEl sáb., 14 de dic. de 2019 a la(s) 19:41, <mattr94@gmail.com> escribió:\n>\n>\n> After going through the code and thinking about this. I think the unexpected results came from git branch not checking out the branch I created.\n> I know git checkout -b master would have been the result I wanted. If I were to create another commit with HEAD checked out instead of master, master would not update, only HEAD would.\n> > I guess the real crime here is that git branch does not checkout the branch created. I don't think I ever wanted to create a branch without checking it out, otherwise I would use git tag.\n>\n> The problem with this is that git tag doesn't create a new branch, but rather just a new tag so running something like:\n>\n> git tag my-tag\n> git checkout my-tag\n> git add .\n> git commit -m \"message\"\n>\n> wouldn't update my-tag either, you would need to create a new branch for that.  Sometimes I want to create a branch without checking it out, as I'm sure many other users do.  Is it an issue of documentation where maybe the behavior isn't clear? It does specifically say this in the description of git branch, but to be fair it is buried 6 paragraphs in\n>\n"},{"id":"388225","messageId":"CAPYjA5am3Qua_c==78ASWffEP5poExWR1XZyVvXEYODMYokfog@mail.gmail.com","threadId":"52459","inReplyTo":"CAPYjA5YsLyeZvimsUqJpcyNCybVFK2+mKRskjQ79OKJHffdSLg@mail.gmail.com","subject":"Re: Head, Branch != Head -> Branch?","fromName":"Joshua Teves","fromEmail":"jbtevespro@gmail.com","sentAt":"2019-12-15T05:36:03Z","receivedAt":"2019-12-15T05:36:16Z","isPatch":false,"sender":{"key":"jbtevespro@gmail.com","avatar":null},"body":"Tomas,\n> In what scenarios would you create a new branch and not check it out?\n\nThese are some examples of cases where I want to make but not checkout\na new branch:\n1. I've made a backup branch in case I'm about to screw up the one I'm\non and want to be able to get back to the branch's current state.\n2. I want a branch at this point because I'm planning on doing working\non multiple, independent features from the same point and don't know\nwhen they'll be merged together, and I can only work on each one a\nlittle at the time. It's nice because I can branch from a point that's\nstable.\n\n> Is there a scenario where you would do this in detached head mode?\n\nSomeone may want to be in detached mode to check out a bug behavior at\nsome commit without modifying the code at all, so there's no sense in\nmaking a new branch.\n\n---\n> Could HEAD attach itself to a nearby branch whenever a command\n> requiring an attached branch is called and HEAD points to a commit\n> with only 1 branch attached to it? This would not include commit,\n> since it does not require an attached branch and thus would not fail\n> on detached mode, this should not break bc because it only affects\n> commands that would otherwise throw an error.\n\nIf they change their mind once detached, it's simple enough to\nreattach by just making a new branch where they're checked out. But if\nyou don't do that, how is git supposed to select a name? There's no\nway to pick a good one other than the current SHA... which is exactly\nhow you'd place yourself currently.\n\n> Alternatively, a more specific error message could be printed,\n> prompting the user to attach their head to the branch on the commit.\n\nThere actually IS a very clear prompt to reattach:\n\"If you want to create a new branch to retain commits you create, you may\ndo so (now or later) by using -b with the checkout command again. Example:\n\n  git checkout -b <new-branch-name>\"\n\nLastly, being in a detached state isn't an error, so I don't see why\nan error message needs to be printed. It's quite clear that you're not\nattached to any branch in particular, and it's quite clear when you\nrun git branch what SHA you're on and that you're detached. I as a\nuser would never want git to try and decide to attach itself to a new\nbranch, it might make the wrong choice and aggravate me. As it stands\nthe documentation and resulting text from commands are both quite\nclear in my opinion.\n\nmattr94,\nI do agree that this is outside a new user's expectation, as Tomas has\nstated, because I've taught many people git and this is a common\nsurprise. However, it's adequately documented and frequently covered\nin tutorials. Moreoever, the commands are consistent: checkout checks\nout a particular commit/branch, branch creates branches. Perhaps the\ndocumentation could be added removing the newline between note and the\nline above, so there's less of a separation between them? That would\ndo a better job of drawing the reader's eye to the note as being\nrelated. (PS, I only count 4 paragraphs, but maybe I'm looking at the\nwrong version?.. sorry if so).\n\nBest,\nJosh\n\nOn Sun, Dec 15, 2019 at 12:33 AM Joshua Teves <jbtevespro@gmail.com> wrote:\n>\n> Tomas,\n> > In what scenarios would you create a new branch and not check it out?\n>\n> These are some examples of cases where I want to make but not checkout a new branch:\n> 1. I've made a backup branch in case I'm about to screw up the one I'm on and want to be able to get back to the branch's current state.\n> 2. I want a branch at this point because I'm planning on doing working on multiple, independent features from the same point and don't know when they'll be merged together, and I can only work on each one a little at the time. It's nice because I can branch from a point that's stable.\n>\n> > Is there a scenario where you would do this in detached head mode?\n>\n> Someone may want to be in detached mode to check out a bug behavior at some commit without modifying the code at all, so there's no sense in making a new branch.\n>\n> ---\n> > Could HEAD attach itself to a nearby branch whenever a command\n> > requiring an attached branch is called and HEAD points to a commit\n> > with only 1 branch attached to it? This would not include commit,\n> > since it does not require an attached branch and thus would not fail\n> > on detached mode, this should not break bc because it only affects\n> > commands that would otherwise throw an error.\n>\n> If they change their mind once detached, it's simple enough to reattach by just making a new branch where they're checked out. But if you don't do that, how is git supposed to select a name? There's no way to pick a good one other than the current SHA... which is exactly how you'd place yourself currently.\n>\n> > Alternatively, a more specific error message could be printed,\n> > prompting the user to attach their head to the branch on the commit.\n>\n> There actually IS a very clear prompt to reattach:\n> \"If you want to create a new branch to retain commits you create, you may\n> do so (now or later) by using -b with the checkout command again. Example:\n>\n>   git checkout -b <new-branch-name>\"\n>\n> Lastly, being in a detached state isn't an error, so I don't see why an error message needs to be printed. It's quite clear that you're not attached to any branch in particular, and it's quite clear when you run git branch what SHA you're on and that you're detached. I as a user would never want git to try and decide to attach itself to a new branch, it might make the wrong choice and aggravate me. As it stands the documentation and resulting text from commands are both quite clear in my opinion.\n>\n> mattr94,\n> I do agree that this is outside a new user's expectation, as Tomas has stated, because I've taught many people git and this is a common surprise. However, it's adequately documented and frequently covered in tutorials. Moreoever, the commands are consistent: checkout checks out a particular commit/branch, branch creates branches. Perhaps the documentation could be added removing the newline between note and the line above, so there's less of a separation between them? That would do a better job of drawing the reader's eye to the note as being related. (PS, I only count 4 paragraphs, but maybe I'm looking at the wrong version?.. sorry if so).\n>\n> Best,\n> Josh\n>\n> On Sat, Dec 14, 2019 at 10:40 PM Tomas Zubiri <me@tomaszubiri.com> wrote:\n>>\n>> It was just a combination of an old gripe I have with expecting git\n>> branch to checkout and conflating (HEAD pointing to a commit and\n>> branch pointing to a commit) with (HEAD pointing to a branch pointing\n>> to a commit).\n>>\n>> In what scenarios would you create a new branch and not check it out?\n>> Is there a scenario where you would do this in detached head mode?\n>>\n>> ---\n>>\n>>  Could HEAD attach itself to a nearby branch whenever a command\n>> requiring an attached branch is called and HEAD points to a commit\n>> with only 1 branch attached to it? This would not include commit,\n>> since it does not require an attached branch and thus would not fail\n>> on detached mode, this should not break bc because it only affects\n>> commands that would otherwise throw an error.\n>> Alternatively, a more specific error message could be printed,\n>> prompting the user to attach their head to the branch on the commit.\n>>\n>> Regards.\n>> El sáb., 14 de dic. de 2019 a la(s) 19:41, <mattr94@gmail.com> escribió:\n>> >\n>> >\n>> > After going through the code and thinking about this. I think the unexpected results came from git branch not checking out the branch I created.\n>> > I know git checkout -b master would have been the result I wanted. If I were to create another commit with HEAD checked out instead of master, master would not update, only HEAD would.\n>> > > I guess the real crime here is that git branch does not checkout the branch created. I don't think I ever wanted to create a branch without checking it out, otherwise I would use git tag.\n>> >\n>> > The problem with this is that git tag doesn't create a new branch, but rather just a new tag so running something like:\n>> >\n>> > git tag my-tag\n>> > git checkout my-tag\n>> > git add .\n>> > git commit -m \"message\"\n>> >\n>> > wouldn't update my-tag either, you would need to create a new branch for that.  Sometimes I want to create a branch without checking it out, as I'm sure many other users do.  Is it an issue of documentation where maybe the behavior isn't clear? It does specifically say this in the description of git branch, but to be fair it is buried 6 paragraphs in\n>> >\n"}]}