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

Re: [RFC PATCH] switch: provide configurable detach

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 6, 2026, 16:36 UTC
Message-ID
<xmqq7bqkcah8.fsf@gitster.g>
In-Reply-To
<njuf62lav6akkmdyqutwk7pim5yutw5cuicjidwpe5eh6qnkqr@4ir6q4uhhvht>
Thibaud CANALE <thican@thican.net> writes:
Show 10 quoted lines
> Its purpose is to provide for git-switch(1) same detach behavior on
> commit it than git-checkout(1) through configuration option
> `checkout.switchDetach`.
>
> Signed-off-by: Thibaud CANALE <thican@thican.net>
> ---
>  Documentation/config/checkout.adoc |  4 ++++
>  builtin/checkout.c                 | 18 +++++++++++++++---
>  t/t2060-switch.sh                  | 27 +++++++++++++++++++++++++++
>  3 files changed, 46 insertions(+), 3 deletions(-)
Sorry, but I am fairly negative on this change.

"switch" was an attempt to give folks an improved experience over "checkout". The implied "--detach" was deliberately removed from the command and I do not think it was a bad move for our user base who wanted to have "switch" that can only be used to switch branches (as opposed to "checkout" that hecks out both files and branches). With fewer choices in a single command that does only a single thing, the hope was to make it simpler to teach.

And it is backwards to make "switch" configurable in that context. It defeats a major point of "git switch".

FWIW, "git checkout" that knows what is and what is not a branch name and does not require "--detach" when detaching to anything that is not a branch name is always available and will not be going away.

Previous: Thibaud CANALENext: Kristoffer Haugsbakk
Message 7 of 9 in “switch: provide configurable detach”
  1. switch: provide configurable detachThibaud CANALE, Apr 4, 2026
  2. PabloApr 4, 2026
  3. Thibaud CANALEApr 4, 2026
  4. D. Ben KnobleApr 4, 2026
  5. Thibaud CANALEApr 4, 2026
  6. switch: provide configurable detachThibaud CANALE, Apr 4, 2026
  7. Junio C HamanoApr 6, 2026
  8. Kristoffer HaugsbakkApr 6, 2026
  9. Junio C HamanoApr 7, 2026

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.