Thread (5 messages) flat view 5 messages, 4 authors, 2021-07-10

Re: PATCH: improve git switch documentation

From: Martin <hidden>
Date: 2021-07-10 11:06:06

On 10/07/2021 12:24, Sergey Organov wrote:
Martin [off-list ref] writes:
quoted
Actually, "new" or "create" would make sense in "git branch". But in
git switch, they actually raise the question "create what?" / "new
what?".
I believe that's because "git switch" tries to do too much. "git switch"
should rather switch between existing branches, and do nothing else. As
I said once in this discussion already: trouble writing good
documentation is often indication of some flaws in the design.

Creating (a branch) is fundamentally different operation than switching
to (a branch), and that's why the former doesn't fit into "git switch".
Right, yes. But creating a branch is often followed by switching to it.

So this is A shortcuts, that I actually think to be fine.
It does add value, as it does speed up a common operation.

Of course you could have
    git create-switch
or
    git branch-switch

I am not sure, that is really an improvement.



There is even discussion to add "-c" for  "copy branch + switch" to git 
switch.
Which I have no personal objection. Only find it regrettable that it 
means an incompatible change to -c. (Never mind that git switch is still 
"experimental". It has been so for a long time, for many people out 
there long enough to forget the "experimental")

And there is even discussion to add "-m" move/rename, to git switch.
Only that for the latter, most people would not even perceive a rename 
as doing a switch/checkout (technically the branchname in HEAD is 
updated, I guess).
So technically
    git branch -m newname
should change the branchname, but NOT update HEAD (detach)?
(Not sure what it does / not tested)
If git branch actually updates HEAD in that case, then "git switch -m" 
would be an identical copy, adding no value, therefore not required.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help