Re: New orphan worktree?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jan 6, 2021 at 8:21 AM Stefan Monnier <monnier@xxxxxxxxxxxxxxxx> 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.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux