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

Re: [PATCH 3/3] builtin/checkout: DWIM with -f -b

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 20, 2010, 21:10 UTC
Message-ID
<7vpqzltnp3.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20100620201137.GA8502@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 22 quoted lines
> I am not sure it is fixing a bug. There are really two possible things
> to be forced during checkout:
>
>   1. throw away local changes
>
>   2. overwrite an existing branch
>
> Right now, "checkout -f" means just (1). This patch makes it _also_ mean
> (2). Do we want to conflate those two cases?
>
> In some sense, it is reasonable for "-f" to mean "force anything that
> might be questionable". But I wonder if it pays to be a little more
> conservative given that this is a safety valve we are talking about. The
> user can of course still split their compound action into:
>
>   git branch [-f] new_branch old_branch
>   git checkout [-f] new_branch
>
> Less convenient, but there is no ambiguity.
>
> I dunno. I don't have a strong feeling on how it should be, but I think
> it is more than a simple bug fix.
Ok, fair enough.

FWIW, I often end up doing this when rebuilding 'pu' (and 'jch' that is used internally that keeps a version of 'next' with cleaner history).

    ... a script to regenerate jch on top of master (and pu on jch)
    $ Meta/Reintegrate master..jch >Meta/redo-jch.sh
    $ Meta/Reintegrate jch..pu >Meta/redo-pu.sh
    ... rewind and rebuild jch on top of updated master
    $ git checkout -f -b jch master
    ... error ... oops
    $ git branch -f jch master
    $ git checkout jch
    $ Meta/redo-jch.sh
    $ git diff next
    ... no output---good.
    $ git checkout -f -b pu jch
    ... error ... oops
    $ git branch -f pu jch
    $ git checkout pu
    $ Meta/redo-pu.sh
Previous: Clemens BuchacherNext: Jeff King
Message 8 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.