{"thread":{"id":"52623","subject":"Fwd: Issue with Git Branch","startedAt":"2020-01-13T00:01:08Z","lastAt":"2020-01-13T11:26:27Z","messageCount":5,"participants":["Jude Guan Wang","Taylor Blau","SZEDER Gábor"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"389643","messageId":"29742805-4992-47E6-9889-F55F5EFBBFF1@clicktherapeutics.com","threadId":"52623","inReplyTo":"56F9DC91-740F-47C7-9C2A-B6B1EC3A12B6@clicktherapeutics.com","subject":"Fwd: Issue with Git Branch","fromName":"Jude Guan Wang","fromEmail":"guan@clicktherapeutics.com","sentAt":"2020-01-13T00:01:04Z","receivedAt":"2020-01-13T00:01:08Z","isPatch":false,"sender":{"key":"guan@clicktherapeutics.com","avatar":null},"body":"Hi, all:\n\tI noticed something weird with my git command. In my local environment I seem to have a branch named `-D`:\n\n\tAnd I don’t remember how I was able to create a branch like that. I tried to do git branch -D/-d this branch but seems not working. I’m assuming the branch infos were kept in .git folder so my question is if there’s anyway I could remove this invalid branch from that folder? My git version is 2.24.0. Thanks for any help in advance.\n\n"},{"id":"389644","messageId":"20200113001143.GA13099@syl.local","threadId":"52623","inReplyTo":"29742805-4992-47E6-9889-F55F5EFBBFF1@clicktherapeutics.com","subject":"Re: Fwd: Issue with Git Branch","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2020-01-13T00:11:43Z","receivedAt":"2020-01-13T00:11:47Z","isPatch":false,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"Hi Jude,\n\nOn Sun, Jan 12, 2020 at 07:01:04PM -0500, Jude Guan Wang wrote:\n> Hi, all:\n> \tI noticed something weird with my git command. In my local\n> \tenvironment I seem to have a branch named `-D`:\n>\n> \tAnd I don’t remember how I was able to create a branch like that. I\n> \ttried to do git branch -D/-d this branch but seems not working. I’m\n> \tassuming the branch infos were kept in .git folder so my question is\n> \tif there’s anyway I could remove this invalid branch from that\n> \tfolder? My git version is 2.24.0. Thanks for any help in advance.\n\nYou can delete oddly-named branches by passing the end-of-options marker\nto 'git branch', like so:\n\n  $ git branch -D --end-of-options -D\n\n(In fact, '--end-of-options' isn't strictly necessary here, and using\n'--' as in 'git branch -D -- -D' will work as well).\n\nIf you do find a reproducible way to create branches named '-D' or\nsimilar, please do let us know, as these are not intended to be valid\nbranch names in general.\n\nThanks,\nTaylor\n"},{"id":"389645","messageId":"20200113004235.GI32750@szeder.dev","threadId":"52623","inReplyTo":"20200113001143.GA13099@syl.local","subject":"Re: Fwd: Issue with Git Branch","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2020-01-13T00:42:35Z","receivedAt":"2020-01-13T00:42:42Z","isPatch":false,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Sun, Jan 12, 2020 at 04:11:43PM -0800, Taylor Blau wrote:\n> On Sun, Jan 12, 2020 at 07:01:04PM -0500, Jude Guan Wang wrote:\n> > \tI noticed something weird with my git command. In my local\n> > \tenvironment I seem to have a branch named `-D`:\n> >\n> > \tAnd I don’t remember how I was able to create a branch like that.\n\n> If you do find a reproducible way to create branches named '-D' or\n> similar, please do let us know, as these are not intended to be valid\n> branch names in general.\n\n  $ git update-ref refs/heads/-D master\n  $ git branch |head -n1\n    -D\n\n"},{"id":"389647","messageId":"20200113004814.GA15236@syl.local","threadId":"52623","inReplyTo":"20200113004235.GI32750@szeder.dev","subject":"Re: Fwd: Issue with Git Branch","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2020-01-13T00:48:14Z","receivedAt":"2020-01-13T00:48:18Z","isPatch":false,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Mon, Jan 13, 2020 at 01:42:35AM +0100, SZEDER Gábor wrote:\n> On Sun, Jan 12, 2020 at 04:11:43PM -0800, Taylor Blau wrote:\n> > On Sun, Jan 12, 2020 at 07:01:04PM -0500, Jude Guan Wang wrote:\n> > > \tI noticed something weird with my git command. In my local\n> > > \tenvironment I seem to have a branch named `-D`:\n> > >\n> > > \tAnd I don’t remember how I was able to create a branch like that.\n>\n> > If you do find a reproducible way to create branches named '-D' or\n> > similar, please do let us know, as these are not intended to be valid\n> > branch names in general.\n>\n>   $ git update-ref refs/heads/-D master\n>   $ git branch |head -n1\n>     -D\n\nI was assuming that Jude had gotten the ref to appear by using 'git\nbranch' alone, i.e., without the help of 'git update-ref' or 'cp\n.git/refs/heads/{master,-D}'.\n\nThanks,\nTaylor\n"},{"id":"389663","messageId":"20200113112621.GJ32750@szeder.dev","threadId":"52623","inReplyTo":"20200113004814.GA15236@syl.local","subject":"Re: Fwd: Issue with Git Branch","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2020-01-13T11:26:21Z","receivedAt":"2020-01-13T11:26:27Z","isPatch":false,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Sun, Jan 12, 2020 at 04:48:14PM -0800, Taylor Blau wrote:\n> On Mon, Jan 13, 2020 at 01:42:35AM +0100, SZEDER Gábor wrote:\n> > On Sun, Jan 12, 2020 at 04:11:43PM -0800, Taylor Blau wrote:\n> > > On Sun, Jan 12, 2020 at 07:01:04PM -0500, Jude Guan Wang wrote:\n> > > > \tI noticed something weird with my git command. In my local\n> > > > \tenvironment I seem to have a branch named `-D`:\n> > > >\n> > > > \tAnd I don’t remember how I was able to create a branch like that.\n> >\n> > > If you do find a reproducible way to create branches named '-D' or\n> > > similar, please do let us know, as these are not intended to be valid\n> > > branch names in general.\n> >\n> >   $ git update-ref refs/heads/-D master\n> >   $ git branch |head -n1\n> >     -D\n> \n> I was assuming that Jude had gotten the ref to appear by using 'git\n> branch' alone, i.e., without the help of 'git update-ref' or 'cp\n> .git/refs/heads/{master,-D}'.\n\nOn a somewhat related note, while trying whether I could\n\"inadvertently\" create such a branch with gitk I stumbled upon this\nbit of weirdness:\n\n  $ git rev-parse v2.24.0^{commit}\n  da72936f544fec5a335e66432610e4cef4430991\n  $ git branch da72936f544fec5a335e66432610e4cef4430991 v2.24.0\n  $ gitk -1 v2.24.0\n\n(While starting up gitk might show a popup warning about the branch\nwith 40 hexdigit name, close it.)\n\nSo now gitk displays a commit with the v2.24.0 tag and the da7293...\nbranch pointing to it.  Right click on the commit's subject line,\nselect \"Create new branch\" from the context menu.  Enter \"-D\" as the\nname of the new branch, and click Create.  Now gitk displays a \"-D\"\nbranch pointing to the same commit as well, but it's only a display\nthing, as it did not actually create that branch, because it\ncarelessly run the 'git branch -D da7293...' command...  After\nrefreshing with F5 it won't display the da7293... and \"-D\" branches.\n\n"}]}