Skip to content

feat: add optional branch deletion after worktree remove#56

Merged
guodong-sq merged 1 commit intomainfrom
guodong/remove-branch-option
Mar 23, 2026
Merged

feat: add optional branch deletion after worktree remove#56
guodong-sq merged 1 commit intomainfrom
guodong/remove-branch-option

Conversation

@guodong-sq
Copy link
Collaborator

Summary

  • Add -b/--branch flag to wt remove that deletes the git branch after removing the worktree
  • In interactive mode (no -y), prompt the user whether to delete the branch
  • If safe delete (git branch -d) fails due to unmerged changes, offer force delete (git branch -D)
  • -y without -b conservatively skips branch deletion entirely
  • Branch checked out in main repo: warn and skip deletion
  • Update help text, bash completions, and zsh completions
  • Add 4 integration tests covering the new behavior

Test plan

  • bats test/unit/ — all 151 tests pass
  • bats test/integration/ — all 145 tests pass (12 existing + 4 new for wt-remove)
  • wt remove -b deletes branch after worktree removal
  • wt remove -y -b deletes branch silently
  • wt remove -y does NOT delete branch (conservative)
  • wt remove --merged still deletes branches (existing behavior preserved)

🤖 Generated with Claude Code

Add -b/--branch flag to `wt remove` that deletes the git branch after
removing the worktree. In interactive mode (no -y), prompt the user.
If safe delete fails (unmerged changes), offer force delete.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@guodong-sq guodong-sq merged commit 3771133 into main Mar 23, 2026
5 checks passed
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