Skip to content

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

Merged
love-linger merged 1 commit into
sourcegit-scm:developfrom
weiningwei:fix/add-worktree-exclude-used-branches
Jul 30, 2026
Merged

fix(AddWorktree): exclude current branch and worktree-attached branches from selection#2581
love-linger merged 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>
@love-linger love-linger self-assigned this Jul 30, 2026
@love-linger love-linger added the enhancement New feature or request label Jul 30, 2026
@love-linger
love-linger merged commit edcf914 into sourcegit-scm:develop Jul 30, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants