{"thread":{"id":"48010","subject":"Case sensitivity when deleting a checked out branch","startedAt":"2018-03-08T19:58:33Z","lastAt":"2018-03-08T19:58:33Z","messageCount":1,"participants":["guillaume weybrecht"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"341312","messageId":"420c2cd9-c38b-8f90-0fec-e070b19efb49@gmail.com","threadId":"48010","inReplyTo":null,"subject":"Case sensitivity when deleting a checked out branch","fromName":"guillaume weybrecht","fromEmail":"guillaume.weybrecht@gmail.com","sentAt":"2018-03-08T19:57:54Z","receivedAt":"2018-03-08T19:58:33Z","isPatch":false,"sender":{"key":"guillaume.weybrecht@gmail.com","avatar":null},"body":"Hello,\n\nI came across an odd behavior in Git related to case sensitivity when \ndeleting a checked out branch.\nI was not able to find much information about it.\n\n$ git checkout -b foo\n$ git branch -d foo       # error: Cannot delete branch 'foo' checked \nout => this is expected, nothing happens since you are on branch 'foo'\n$ git branch -d Foo       # Deleted branch Foo => this is not expected, \nGit removed 'foo' from .git/refs/heads\n\nGit removed the 'foo' file from .git/refs/heads, but did not update the \n.git/HEAD file which still contains \"ref: refs/heads/foo\".\n\nIn fact, everything looks like a \"git checkout --orphan foo\":\n$ git status              # On branch foo. No commits yet (the working \ntree is staged)\n$ git log                 # fatal: your current branch 'foo' does not \nhave any commits yet\n$ git rev-parse HEAD --   # fatal: bad revision 'HEAD'\n$ git fsck                # notice: HEAD points to an unborn branch (foo)\n\nYou can run \"git checkout <other_branch>\" to get back on your feet as \nyou would after \"git checkout --orphan foo\".\n\nThe thing is, you get there unexpectedly without any warning, just with \na case sensitivity mistake in \"git branch -d\".\nEven it is seems unlikely to happen, someone ran into this at my job.\n\nTested on Windows 2.15.1.windows.2 and 2.16.2.windows.1, and on Mac OS \n(I think it was a 2.14 version).\n\nBest regards,\nGuillaume\n\n---\nL'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.\nhttps://www.avast.com/antivirus\n\n"}]}