Subject: Re: [RFC PATCH] switch: provide configurable detach

From: Junio C Hamano <[email-masked]>
Date: Mon, 06 Apr 2026 09:36:03 -0700

Thibaud CANALE <[email-masked]> writes:

> 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 <[email-masked]>
> ---
>  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.