Syntax
Description
Interactively remove worktrees for the current repository. Provides a searchable interface to select and remove worktrees one at a time. The command continues to prompt for worktrees to remove until you cancel (Ctrl+C or ESC).Aliases
rm- Short alias for remove
Interactive Flow
The command provides an interactive search interface:Examples
Remove worktrees interactively
Using the short alias
Search Functionality
The search is case-insensitive and matches against:- Branch name (e.g.,
feature-auth) - Worktree directory name (e.g.,
myapp-feature-auth) - Full path (e.g.,
/Users/john/projects/myapp-feature-auth)
- Type
feat- Shows all worktrees with “feat” in branch or path - Type
auth- Shows worktrees containing “auth” - Type
projects/- Shows worktrees in a specific directory
Confirmation
Before removing each worktree, you’ll see a confirmation prompt:- Select “Yes” to remove the worktree
- Select “No” to skip and continue searching
- Press ESC or Ctrl+C to exit
Removal Process
For each confirmed removal:- Git Command - Executes
git worktree remove "<path>" --force - Fallback - If git command fails, uses filesystem removal (
rm -rf) - Registry Update - Removes entry from
~/.gwtree/worktrees.json - Confirmation - Shows success or error message
Continuous Mode
After removing a worktree, the search prompt appears again, allowing you to remove multiple worktrees in one session:Exiting
To exit the remove command:- Press ESC during search
- Press Ctrl+C at any time
When No Worktrees Exist
If no worktrees are found:Force Removal
The command always uses--force flag with git worktree remove to handle:
- Worktrees with uncommitted changes
- Worktrees with untracked files
- Modified worktrees
Safety Features
- Confirmation Required - Never removes without explicit confirmation
- Search First - See what you’re removing before confirming
- One at a Time - Removes worktrees sequentially, not in batch
- Registry Cleanup - Automatically updates internal tracking
Branch Handling
Theremove command only removes the worktree directory and registry entry. The git branch remains intact.
To remove the branch as well, use:
gwt merge which removes both worktree and branch.
Comparison with Other Commands
| Command | Purpose | Confirmation | Batch |
|---|---|---|---|
gwt remove | Interactive removal | Per worktree | No |
gwt clean | Remove merged | Once | Yes |
gwt merge | Merge & remove | Per operation | No |
Exit Codes
0- Success (worktrees removed or operation cancelled)1- Error (not in a git repository)