sourcegit icon indicating copy to clipboard operation
sourcegit copied to clipboard

[FR] Pleas add create worktree base on remot-branch

Open heartacker opened this issue 5 months ago • 5 comments

but you can creat a branch and set the upstream😅, then you can get a branch base that remote,

eeeerrr

heartacker avatar Aug 05 '25 11:08 heartacker

If you want to create a worktree by checking out a remote branch. You should use Create New Branch method to add worktree, and then input the remote branch name (you can copy it from context menu).

For example:

Image

love-linger avatar Aug 05 '25 12:08 love-linger

Entry: Popup

  1. base current branch
    name: user input error: if name exits in local branch, ERROR

  2. use local branch name: user select error: if a worktree named as that branch has checkouted, ERROR

  3. use remote branch name: user select a. if a local branch has the same name, use the local branch, then check the local branch status error: if the local branch is related to a worktree, Error

    b. if no local branch named it, creat a local branch and auto set the upstream this remote branch

Entry: Commit

  1. Select a commit and open the menu
  2. creat a local branch base select commit and then create a worktree

heartacker avatar Aug 06 '25 03:08 heartacker

This is a limitation of Git itself: a branch can only be checked out in one worktree, and the same branch cannot be checked out in multiple worktrees. If you need a worktree for a remote branch, you should first check out this remote branch locally and then use the "Existing Branch" option to check it out—or choose the "Create New Branch" option and set the upstream branch.

gadfly3173 avatar Aug 06 '25 08:08 gadfly3173

a branch can only be checked out in one worktree

yes ,we get this

as I notice above, we are trying to make a useful and comfortable way to create worktree without Too many steps

I have sorted out three scenarios, and each scenario has its own processing method to ensure uniqueness. Moreover, the interface will be very convenient to use, without the need for additional steps as you mentioned.

heartacker avatar Aug 06 '25 08:08 heartacker

sort out the scene and clarify the train of thought, We just need to make some changes to handle these scenarios very well,

heartacker avatar Aug 06 '25 08:08 heartacker