Skip to content

feat: add git-worktree-branch-delete command#211

Merged
avihut merged 9 commits intomasterfrom
daft-166/gwtbd
Feb 16, 2026
Merged

feat: add git-worktree-branch-delete command#211
avihut merged 9 commits intomasterfrom
daft-166/gwtbd

Conversation

@avihut
Copy link
Owner

@avihut avihut commented Feb 16, 2026

Summary

  • Add git-worktree-branch-delete (gwtbd) command that fully deletes a branch: its worktree, local branch, and remote tracking branch as a single atomic-feeling operation
  • Implements validate-then-execute pattern: all safety checks run for every branch before any deletions begin, aborting entirely if any fail (unless --force/-D)
  • Safety checks: branch exists, not default branch, no uncommitted changes, merged into default (with squash merge detection via git cherry), local/remote in sync
  • Supports multiple branches in a single invocation, --quiet/--verbose flags, and current-worktree deferral with CD target resolution

Fixes #166

Test Plan

  • 310 unit tests pass (including 11 new branch_delete tests)
  • 192 integration tests pass across both default and gitoxide matrix entries (including 8 new branch_delete integration tests)
  • Clippy passes with zero warnings
  • Man pages verified up-to-date
  • Docs site builds successfully
  • Integration tests cover: basic delete, unmerged refusal, force override, default branch protection, dirty worktree refusal, multiple branches, no-worktree branch, nonexistent branch

🤖 Generated with Claude Code

avihut and others added 8 commits February 16, 2026 08:38
Design document for issue #166: a command that fully deletes a branch
including its worktree, local branch, and remote tracking branch with
safety checks modeled after git branch -d.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
8-task plan covering: git method additions, command scaffolding,
validation phase, execution phase, integration tests, man/CLI docs,
docs site updates, and final verification.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add merge_base_is_ancestor, cherry, push_delete,
has_uncommitted_changes_in, and rev_parse methods to GitCommand.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add command module, routing, shortcut (gwtbd), help docs registration,
xtask integration, and suggest support. Implementation is a placeholder.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add safety checks: branch exists, not default branch, no uncommitted
changes, merged into default (with squash detection), local/remote in
sync. Validate-then-execute ensures no partial state.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Delete remote branch, remove worktree, delete local branch with hooks
and cleanup. Current worktree deferred to last with CD target resolution.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Cover basic delete, unmerged refusal, force override, default branch
protection, dirty worktree refusal, multiple branches, no-worktree
branch, and nonexistent branch.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove the --no-cd flag from branch-delete: when deleting the current
worktree the CD is mandatory (nowhere to stay), and for other branches
it's irrelevant. Also remove design and plan documents that are
development artifacts, not permanent documentation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@avihut avihut added this to the v1.1.0 milestone Feb 16, 2026
@avihut avihut added the feat New feature label Feb 16, 2026
@avihut avihut self-assigned this Feb 16, 2026
@avihut avihut merged commit d2c8a54 into master Feb 16, 2026
4 checks passed
@avihut avihut deleted the daft-166/gwtbd branch February 16, 2026 11:22
This was referenced Feb 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Worktree branch delete command

1 participant