git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 3/3] builtin/checkout: learn -B

From
Tay Ray Chuan <rctay89@gmail.com>
Date
Jun 23, 2010, 19:13 UTC
Message-ID
<AANLkTinBBuxPKiflz1qMvbuNk8ACSN8IjVcAbefawony@mail.gmail.com>
In-Reply-To
<7vr5jxegvd.fsf@alter.siamese.dyndns.org>
On Thu, Jun 24, 2010 at 2:36 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 24 quoted lines
> Tay Ray Chuan <rctay89@gmail.com> writes:
>
>> 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.
hmm - would
  git checkout <branch> && git reset --keep <start point>
make the cut?
-- 
Cheers,
Ray Chuan
Previous: Junio C HamanoNext: Erick Mattos
Message 18 of 29 in “DWIM with "git checkout -f -b"”
  1. 0/3 DWIM with "git checkout -f -b"Tay Ray Chuan, Jun 20, 2010
  2. 1/3 add tests for checkout -bTay Ray Chuan, Jun 20, 2010
  3. 2/3 t2018-checkout-branch.sh: show that checkout -f -b doesn't DWIMTay Ray Chuan, Jun 20, 2010
  4. 3/3 builtin/checkout: DWIM with -f -bTay Ray Chuan, Jun 20, 2010
  5. Junio C HamanoJun 20, 2010
  6. Jeff KingJun 20, 2010
  7. Clemens BuchacherJun 20, 2010
  8. Junio C HamanoJun 20, 2010
  9. Jeff KingJun 20, 2010
  10. Junio C HamanoJun 21, 2010
  11. Tay Ray ChuanJun 21, 2010
  12. Junio C HamanoJun 21, 2010
  13. 0/3 teach git-checkout -B WAS builtin/checkout: DWIM with -f -bTay Ray Chuan, Jun 21, 2010
  14. 1/3 add tests for checkout -bTay Ray Chuan, Jun 21, 2010
  15. 2/3 builtin/checkout: change -b from an OPTION_STRING to a OPTION_SET_INTTay Ray Chuan, Jun 21, 2010
  16. 3/3 builtin/checkout: learn -BTay Ray Chuan, Jun 21, 2010
  17. Junio C HamanoJun 23, 2010
  18. Tay Ray ChuanJun 23, 2010
  19. Erick MattosJun 21, 2010
  20. Tay Ray ChuanJun 23, 2010
  21. Erick MattosJun 23, 2010
  22. Tay Ray ChuanJun 21, 2010
  23. Erick MattosJun 21, 2010
  24. 0/3 teach git-checkout -B WAS builtin/checkout: DWIM with -f -bTay Ray Chuan, Jun 23, 2010
  25. 1/3 add tests for checkout -bTay Ray Chuan, Jun 23, 2010
  26. 2/3 builtin/checkout: reword hint for -bTay Ray Chuan, Jun 23, 2010
  27. 3/3 builtin/checkout: learn -BTay Ray Chuan, Jun 23, 2010
  28. Michel LespinasseJun 21, 2010
  29. Michel LespinasseJun 21, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.