Re: [PATCH/RFC] builtin-checkout: suggest creating local branch when appropriate to do so
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 6, 2009, 20:33 UTC
- Message-ID
- <7vzl84xnx0.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <76c5b8580910060943k6172e3a5waee2f92c403e5cc3@mail.gmail.com>
Eugene Sajine <euguess@gmail.com> 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 <new_branch_name>
...As to Mikael's scenario:
Show 9 quoted lines
>>> 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.