Re: git checkout -B <branch> lets you checkout a branch that is already checked out in another worktree Inbox

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

 



On 23/11/2023 05:58, Junio C Hamano wrote:
Junio C Hamano <gitster@xxxxxxxxx> writes:

I guess we could change the behaviour so that

     git checkout -B <branch> [<start-point>]

fails when <branch> is an existing branch that is in use in another
worktree, and allow "-f" to be used to override the safety, i.e.,

     git checkout -f -B <branch> [<start-point>]

would allow the <branch> to be repointed to <start-point> (or HEAD)
even when it is used elsewhere.

It turns out that for some reason "-f" is not how we decided to
override this one---there is "--ignore-other-worktrees" option.

Presumably that's because -f means throwing away any local changes that are in the way of checking out the new HEAD, which you wouldn't necessarily want when trying to replace an existing branch.

Andy




[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