Re: changing the experimental 'git switch' (was: [Summit topic] Improving Git UX)
- From
- Martin <git@mfriebe.de>
- Date
- Oct 24, 2021, 06:54 UTC
- Message-ID
- <da952e81-70f9-886b-42ff-2ec850f55fa0@mfriebe.de>
- In-Reply-To
- <9c6b3041-a5c0-6fe1-860e-7bfcb292ae81@mfriebe.de>
On 22/10/2021 16:04, martin wrote:
> Unless there is more, than the copying of the reflog, wouldn't it be > better to add an option "--copy-reflog"
Ok, I found the answer (actually 2 / see other mail)
> The |-c| and |-C| options have the exact same semantics as |-m| and > |-M|, except instead of the branch being renamed, it will be copied to > a new name, along with its config and reflog.
As for the "config" being part depends on which part of the man-page one reads.
But, anyway on the topic of "git switch"
Copying a branch (and maybe moving too) could be seen as an extension to creating a new one. After all, after the copy operation there is a newly created branch. Only it has some more data with it.
So one could do git switch --settings-from <branch-with-reflog-and-conf> --create <new-branch> <commit> git switch -s <branch-with-reflog-and-conf> -c <new-branch> <commit>
"settings-from" is just an example, there may be better names for it. Ideally not starting with a "c".
And using a name different from "copy" may be more accurate, because unless it is created on the same one <commit> to which the <branch-with-reflog-and-conf> points, then its at best partially copied.
On top of that options could be brought in, to copy only reflog or only config.
Using the above with an --force-create / -C would make it a "move branch". In this case there could be a shortcut, if <branch-with-reflog-and-conf> and (the old) <new-branch> are the same.