Re: New orphan worktree?
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Jan 6, 2021, 20:01 UTC
- Message-ID
- <CAPig+cRzXd+zd+xVisaW+HToSaGzAE28acGmxwRxNU4bczHXbw@mail.gmail.com>
- In-Reply-To
- <CABPp-BE1QXA0ohB9D-tqKpzDTok0BMsGQjotmcqMxfs9AL5noA@mail.gmail.com>
On Wed, Jan 6, 2021 at 2:41 PM Elijah Newren <newren@gmail.com> wrote:
Show 9 quoted lines
> On Wed, Jan 6, 2021 at 8:21 AM Stefan Monnier <monnier@iro.umontreal.ca> wrote: > > I wish I could just do something like: > > > > git worktree add --orphan foo newbranch > > 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.
I'm also curious about a use-case in which orphaned branches are used so frequently.
Nevertheless, I'm not at all opposed to seeing an --orphan option added to `git worktree add`. In fact, --orphan has been on the radar[1] from the very beginning. Although the original implementation of `git worktree add` mimicked a small set of options from git-checkout, the plan all along was to mimic additional options from git-checkout as demand for them arose, and several such options have already been added.
> 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.
Yep, when/if --orphan is added to `git worktree add`, it should mimic the behavior of --orphan in git-switch rather than git-checkout.
Patches are welcome.
[1]: https://lore.kernel.org/git/CAPig+cQiJnrnz4jsGdT0=8kYogWfsNkjq5WQCGC4Zk6res5mtg@mail.gmail.com/