From: Junio C Hamano Date: Tue, 06 Oct 2009 20:33:47 GMT Subject: Re: [PATCH/RFC] builtin-checkout: suggest creating local branch when appropriate to do so Message-ID: <7vzl84xnx0.fsf@alter.siamese.dyndns.org> In-Reply-To: <76c5b8580910060943k6172e3a5waee2f92c403e5cc3@mail.gmail.com> Eugene Sajine writes: > As for the solution i would choose the "simplest thing that will work" - so > i think that we just have to notify user about his suicide attempt to > checkout nonlocal branch and offer him a correct syntax to go with. We already do that, without going interactive, for warning unintended detachment: $ git checkout origin/next Note: moving to 'origin/next' which isn't a local branch If you want to create a new branch from this checkout, you may do so (now or later) by using -b with the checkout command again. Example: git checkout -b ... As to Mikael's scenario: >>> I can imagine this happening: >>> % git clone git://git.git git >>> % git checkout next >>> do you want to checkout origin/next? y >>> # a few days later >>> % git fetch >>> % git checkout next >>> [freenode] /join #git >>> [#git] i did git checkout next but my files are still the same? No amount of sugarcoating the checkout syntax changes the fact that in the user's repository there _are_ two distinct refs, origin/next and next, and the "fetch few days later" updates only the former but never the latter. It can only be fixed by injecting a bit of clue to the user, in a way Dscho suggested in the thread.