Skip to content

feat: add 'Remove worktree and branch' option when deleting a branch checked out by a worktree#5557

Open
toller892 wants to merge 1 commit intojesseduffield:masterfrom
toller892:feat/remove-worktree-and-branch
Open

feat: add 'Remove worktree and branch' option when deleting a branch checked out by a worktree#5557
toller892 wants to merge 1 commit intojesseduffield:masterfrom
toller892:feat/remove-worktree-and-branch

Conversation

@toller892
Copy link
Copy Markdown

Description

When deleting a branch that is currently checked out by a worktree, users currently have three options:

  1. Switch to worktree
  2. Detach worktree
  3. Remove worktree

If the user wants to delete BOTH the worktree and the branch, they must first remove the worktree, then delete the branch in a second step. This adds a fourth option that combines both operations.

Closes #5205

Changes

  • Added RemoveWorktreeAndBranch i18n string
  • Added fourth menu item in promptWorktreeBranchDelete() that calls worktreeHelper.Remove() followed by Branch.LocalDelete()

Testing

  • go build ./...
  • go test ./pkg/i18n/ ./pkg/gui/controllers/helpers/

…checked out by a worktree

When deleting a branch that is currently checked out by a worktree,
users previously had to remove the worktree first, then delete the
branch in a second step. This adds a new menu option that combines
both operations into a single action.

Closes jesseduffield#5205
@sp71
Copy link
Copy Markdown

sp71 commented Apr 30, 2026

Don't think we need an extra option. Just update the existing delete local branch to also delete the corresponding worktree. It's pointless to have a dangling worktree for a non-existent branch. I'm not sure git even allows this unless you force delete the branch. If the want to delete the worktree but keep the branch, they can go to the worktree panels and delete there

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.

Remove worktree and branch at the same time

2 participants