Re: [PATCH 3/3] builtin/checkout: learn -B
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 23, 2010, 18:36 UTC
- Message-ID
- <7vr5jxegvd.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <1277140782-4064-4-git-send-email-rctay89@gmail.com>
Tay Ray Chuan <rctay89@gmail.com> writes:
Show 15 quoted lines
> diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt > index 261dd90..5849e13 100644 > --- a/Documentation/git-checkout.txt > +++ b/Documentation/git-checkout.txt > @@ -31,6 +31,13 @@ were called and then checked out; in this case you can > use the `--track` or `--no-track` options, which will be passed to > 'git branch'. As a convenience, `--track` without `-b` implies branch > creation; see the description of `--track` below. > ++ > +If `-B` is given, <branch> is created if it doesn't exist; otherwise, it > +is reset. This is equivalent to > ++ > +------------ > +$ git branch -f <branch> [<start point>] && git checkout <branch> > +------------
It is somewhat sad if these are truly equivalent. In the above sequence, "git checkout <branch>" could stop to prevent you from clobbering your local changes, but at that point the branch has already been updated.
I was hoping that the check (and stop) can be done first and then the branch head is cloberred after you know you will succeed the checkout.