Re: New orphan worktree?
From: Elijah Newren <hidden>
Date: 2021-01-06 19:41:19
On Wed, Jan 6, 2021 at 8:21 AM Stefan Monnier [off-list ref] wrote:
I use worktrees extensively (and rarely use `git checkout`).
When I need to create a new orphan branch with a new matching worktree
(or submodule), I find it is quite cumbersome. I basically have
to do something like:
git worktree add -b dummy foo
cd foo git checkout --orphan newbranch
git rm -rf .Sidenote: Yeah, checkout --orphan is broken. You should use switch --orphan, which doesn't require the extra 'git rm -rf .' step. That bit is definitely cumbersome.
git branch -D dummy
I wish I could just do something like:
git worktree add --orphan foo newbranch
I think you mean
git worktree add --orphan newbranch foo
cd foo
Because (a) the option to --orphan is the name of the new branch, and
(b) you need the cd to be equivalent to the first sequence of
commands.
Out of curiosity, why are you frequently creating orphan branches?
Such an option would drop the number of commands you need to run from
four down to two, but I'm surprised this would come up enough to
matter enough to do much more than create a personal git alias for it.