Skip to content

fix(AddWorktree): exclude current branch and worktree-attached branches from selection - #2581

Open
weiningwei wants to merge 1 commit into
sourcegit-scm:developfrom
weiningwei:fix/add-worktree-exclude-used-branches
Open

fix(AddWorktree): exclude current branch and worktree-attached branches from selection#2581
weiningwei wants to merge 1 commit into
sourcegit-scm:developfrom
weiningwei:fix/add-worktree-exclude-used-branches

Conversation

@weiningwei

Copy link
Copy Markdown
Contributor

When adding a new worktree via the "Add Worktree" dialog, the branch selection list includes all local branches unconditionally. Selecting a branch that is already checked out in the current repository or attached to another worktree causes Git to fail with a fatal error, e.g.: fatal: 'develop' is already used by worktree at 'E:/code/2026-07/sourcegit'

Filter out ineligible branches in AddWorktree constructor before adding them
to LocalBranches:

  • Current branch (branch.IsCurrent) — excluded because it is already checked out in the active worktree.
  • Branches attached to another worktree (branch.HasWorktree) — excluded because they are already in use by an existing worktree.

…worktree

Signed-off-by: weiningwei <weiningwei09@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant