{"thread":{"id":"29392","subject":"Checking out orphans with -f","startedAt":"2012-01-18T19:07:05Z","lastAt":"2012-01-18T23:12:15Z","messageCount":5,"participants":["Martin Fick","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"182735","messageId":"201201181207.05967.mfick@codeaurora.org","threadId":"29392","inReplyTo":null,"subject":"Checking out orphans with -f","fromName":"Martin Fick","fromEmail":"mfick@codeaurora.org","sentAt":"2012-01-18T19:07:05Z","receivedAt":"2012-01-18T19:07:05Z","isPatch":false,"sender":{"key":"mfick@codeaurora.org","avatar":null},"body":"I am trying to write some scripts which do various things to \na git repo and I have run into a issue where I think that \ngit behavior with respect to orphan branches is potentially \nundesirable.  If I type:\n\n  git checkout --orphan a\n\nI cannot easily abandon this state by simply typing:\n\n  git check -f --orphan b\n\nIs there a better simpler way to abandon a that I am not \naware of?  Am I miss understanding what -f is supposed to \ndo?  It seems like it should allow me to abandon the a \norphan and continue to checkout the b orphan?\n\nThanks for any insights,\n\n-Martin\n\n-- \nEmployee of Qualcomm Innovation Center, Inc. which is a \nmember of Code Aurora Forum\n"},{"id":"182747","messageId":"7vsjjcljmj.fsf@alter.siamese.dyndns.org","threadId":"29392","inReplyTo":"201201181207.05967.mfick@codeaurora.org","subject":"Re: Checking out orphans with -f","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-18T22:40:36Z","receivedAt":"2012-01-18T22:40:36Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Martin Fick <mfick@codeaurora.org> writes:\n\n> I am trying to write some scripts which do various things to \n> a git repo and I have run into a issue where I think that \n> git behavior with respect to orphan branches is potentially \n> undesirable.  If I type:\n>\n>   git checkout --orphan a\n>\n> I cannot easily abandon this state\n\nWhat do you mean by \"abandon\"?\n\nIf you want to remove a branch \"a\" because you do not need it, you can\ncheck out some other branch and say \"git branch -D a\", no?\n"},{"id":"182748","messageId":"201201181545.30043.mfick@codeaurora.org","threadId":"29392","inReplyTo":"7vsjjcljmj.fsf@alter.siamese.dyndns.org","subject":"Re: Checking out orphans with -f","fromName":"Martin Fick","fromEmail":"mfick@codeaurora.org","sentAt":"2012-01-18T22:45:29Z","receivedAt":"2012-01-18T22:45:29Z","isPatch":false,"sender":{"key":"mfick@codeaurora.org","avatar":null},"body":"On Wednesday, January 18, 2012 03:40:36 pm Junio C Hamano \nwrote:\n> Martin Fick <mfick@codeaurora.org> writes:\n> > I am trying to write some scripts which do various\n> > things to a git repo and I have run into a issue where\n> > I think that git behavior with respect to orphan\n> > branches is potentially\n> > \n> > undesirable.  If I type:\n> >   git checkout --orphan a\n> > \n> > I cannot easily abandon this state\n> \n> What do you mean by \"abandon\"?\n> \n> If you want to remove a branch \"a\" because you do not\n> need it, you can check out some other branch and say\n> \"git branch -D a\", no?\n\nBy abandon, I simply mean to check out another branch, which \nas you point, I can almost do.  I just can't do it by \nchecking out another orphaned branch!  Why not, this seems \ninconsistent?  In both cases I loose what the original \norphaned branch (a) is, so why prevent me from doing it in \nthe one case and not the other?\n\n-Martin\n\n-- \nEmployee of Qualcomm Innovation Center, Inc. which is a \nmember of Code Aurora Forum\n"},{"id":"182750","messageId":"201201181550.23792.mfick@codeaurora.org","threadId":"29392","inReplyTo":"7vsjjcljmj.fsf@alter.siamese.dyndns.org","subject":"Re: Checking out orphans with -f","fromName":"Martin Fick","fromEmail":"mfick@codeaurora.org","sentAt":"2012-01-18T22:50:23Z","receivedAt":"2012-01-18T22:50:23Z","isPatch":false,"sender":{"key":"mfick@codeaurora.org","avatar":null},"body":"On Wednesday, January 18, 2012 03:40:36 pm Junio C Hamano \nwrote:\n> Martin Fick <mfick@codeaurora.org> writes:\n> > I am trying to write some scripts which do various\n> > things to a git repo and I have run into a issue where\n> > I think that git behavior with respect to orphan\n> > branches is potentially\n> > \n> > undesirable.  If I type:\n> >   git checkout --orphan a\n> > \n> > I cannot easily abandon this state\n> \n> What do you mean by \"abandon\"?\n> \n> If you want to remove a branch \"a\" because you do not\n> need it, you can check out some other branch and say\n> \"git branch -D a\", no?\n\nActually, no I can't.  I can check out some other branch \n(assuming I have one), but I cannot then delete a, it \nappears to already be deleted by virtue of checking out \nanother branch.  I like that since I never checked it in, \nbetter to clean up the garbage, but why can't I then \ncheckout another orphan to do the same thing?\n\n-Martin\n\n-- \nEmployee of Qualcomm Innovation Center, Inc. which is a \nmember of Code Aurora Forum\n"},{"id":"182753","messageId":"7vk44oli5s.fsf@alter.siamese.dyndns.org","threadId":"29392","inReplyTo":"201201181550.23792.mfick@codeaurora.org","subject":"Re: Checking out orphans with -f","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-18T23:12:15Z","receivedAt":"2012-01-18T23:12:15Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Martin Fick <mfick@codeaurora.org> writes:\n\n> Actually, no I can't.  I can check out some other branch \n> (assuming I have one), but I cannot then delete a, it \n> appears to already be deleted by virtue of checking out \n> another branch.  I like that since I never checked it in, \n> better to clean up the garbage.\n\nGood.\n\n> ...but why can't I then \n> checkout another orphan to do the same thing?\n\nI am not surprised if the original contributor who wanted to add --orphan\ndid not address corner cases.  It is very plausible that we did not try as\nhard to nitpick the code for complete support of such corner cases as I\nand other contributors usually do for more important features.\n\nSo... Patches welcome ;-)\n\nHaving said that, there are many things to consider to fill the corner\ncase you seem to be interested to add support for.\n\nThe \"orphaned\" state is like immediately after \"git init\". Because you do\nnot have any current commit, you cannot create an orphan branch based the\nstate immediately after \"git init\", either. You are nominally on your\n'master' branch, but it does not have anything yet; you are expected to\nturn it into a real branch by creating a commit soon, but until you do so,\nyou are kind of in-limbo. It is understandable that there will be many\noperations that will not make any sense until you first get out of this\nin-limbo state.  For example, you cannot (and do not have to) delete the\nbranch and if you have a commit (e.g. you can fetch one from another\nplace) you can check it out and the 'master' will be gone, because you\nnever created it in the first place.\n"}]}