Thread (37 messages) flat view 37 messages, 4 authors, 2021-07-12

RE: switch requires --detach [[Re: What actually is a branch]]

From: Felipe Contreras <hidden>
Date: 2021-07-09 16:21:09

Martin wrote:
On 09/07/2021 17:08, Felipe Contreras wrote:
quoted
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.
Yes, and that's a good thing, but there's no need to cripple advaned
users.
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?
No. As you noted it has value for beginners.
- add --allow-detach  and git config switch.detach allow ?
That's a good option, but another one would be to have a core.advanced
mode, you turn it on if you are an advanced user.
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.
That warning olny appears with `git checkout`, not with
`git switch --detach`.
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.
That's definitely a bug.

-- 
Felipe Contreras
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help