switch requires --detach [[Re: What actually is a branch]]
- From
- Martin <git@mfriebe.de>
- Date
- Jul 9, 2021, 15:23 UTC
- Message-ID
- <57f316cb-850d-706a-592b-4376f240e032@mfriebe.de>
- In-Reply-To
- <60e8666c8707f_2153208c0@natae.notmuch>
On 09/07/2021 17:08, Felipe Contreras wrote:
> and the fact that > `git switch` expects branches is one of the things that bothers me about > it.
Ah, good point.
I would word it differently though. "git switch forces the use of --detach if switching to a non branch"
Bit of a twist. It's a nice safety for beginners. I remember when I started, I kept ending up detached. And I had no idea what to do next.
But once you are a bit more experienced the need to add that option can be bothersome. It's not common in my workflow, but I can see that it can be an issue.
So how to remedy?
- Drop the option / Make it default? - add --allow-detach and git config switch.detach allow ?
I don't really have a preference.
I think its a nice protection, but even without it, the warning on entering detached HEAD state is pretty good.
There is also a curious side effect.
If you went into detached, you can go back to attached using git switch -
but not back to detached by again doing git switch -
Even though you had been there, and that means you had used --detached, and therefore known what you did.