As for "git switch -C"
This should IMHO change to (the 2nd arg, actually depends on the point
"1" above)
git switch (-c|-C) <branch-name> [<base-commit>]
I suggest to not call it "new-branch-name" because, it might be an
existing name.
I think the name is all wrong. As Ævar pointed out --new (-n) is much
better. Also it doesn't make much sense to use "create" or "new" for
something that already exists.
The n versus c issue is IMHO separate. Maybe tiny overlaps.
I see it mostly in the light of -c should be for "copy".
On "git checkout" it is "-b" for branch. That works, if you perceive
"branch" as a verb. "The action of branching creates a new branch".
If needs must, that would work as "git switch -b" to.
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".
Thanks,
--
Sergey Organov
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".
So I prefer your suggestion. Also make `git switch` also switches tags
or random commits (like `git checkout <tag>` and `git checkout <commit>`).
--
An old man doll... just what I always wanted! - Clara
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.
From: Felipe Contreras <hidden> Date: 2021-07-10 19:52:00
Sergey Organov wrote:
Martin [off-list ref] writes:
quoted
On 09/07/2021 18:10, Felipe Contreras wrote:
quoted
Martin wrote:
quoted
As for "git switch -C"
This should IMHO change to (the 2nd arg, actually depends on the point
"1" above)
git switch (-c|-C) <branch-name> [<base-commit>]
I suggest to not call it "new-branch-name" because, it might be an
existing name.
I think the name is all wrong. As Ævar pointed out --new (-n) is much
better. Also it doesn't make much sense to use "create" or "new" for
something that already exists.
The n versus c issue is IMHO separate. Maybe tiny overlaps.
I see it mostly in the light of -c should be for "copy".
On "git checkout" it is "-b" for branch. That works, if you perceive
"branch" as a verb. "The action of branching creates a new branch".
If needs must, that would work as "git switch -b" to.
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.
I don't know if it's trying to do too much. I know `git checkout` is
trying to do too much, and I've been trying to use `git switch` instead
for a while. I often create branches and switch to them using
`git switch -c` (which I think should be `git switch -n`).
In my mind it's "switch to a new branch".
So, how would I do this operation (create a new branch and switch to
it), without using `git checkout` or `git switch -c`?
As I said once in this discussion already: trouble writing good
documentation is often indication of some flaws in the design.
Completely agree. But I believe the difficulty is in the semantics of
what a branch means in git, not anything to do with `git switch` per se.
Creating (a branch) is fundamentally different operation than switching
to (a branch), and that's why the former doesn't fit into "git switch".
Not in my mind. Instead of switching to an existing branch, I'm switching
to a new branch, which is easily understood by
`git switch --new branch`.
--
Felipe Contreras
From: Felipe Contreras <hidden> Date: 2021-07-10 20:00:35
Martin wrote:
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")
This is relative.
`git switch` has existed for 1.9 years. I've been using git for about 15
years, so that's 13% of the time (although I've been using it even less
time than that). I understand that for more recent users this might seem
like a long time, but it isn't.
Git UI development is dead slow.
--
Felipe Contreras