Remove a git worktree, delete its branch, and stop its running services
Removes a git worktree, deletes its branch, and cleans up associated files and processes.
/plugin marketplace add eduardoarantes/claude-code-plugin-marketplace/plugin install git-simple@code-plugin-marketplace<branch-name>claude-sonnet-4-5-20250929Remove an existing git worktree from the trees/ directory AND delete the associated git branch. removing the worktree directory, and permanently deleting the branch. This ensures complete cleanup without orphaned processes or files.
PROJECT_CWD: . (current working directory - the main project root)
BRANCH_NAME: $1 (required)
WORKTREE_DIR: trees/<BRANCH_NAME>
PROJECT_CWD/trees/<BRANCH_NAME>git worktree listgit worktree remove trees/<BRANCH_NAME>git worktree remove trees/<BRANCH_NAME> --forcegit worktree list | grep trees/<BRANCH_NAME>git branch -d <BRANCH_NAME>git branch -D <BRANCH_NAME>git branch --list <BRANCH_NAME>git worktree listgit branch --list <BRANCH_NAME>Follow the Report section format below to provide comprehensive removal information.
After successful worktree removal, provide a detailed report in the following format:
ā
Git Worktree and Branch Removed Successfully!
š Worktree Details:
Location: trees/<BRANCH_NAME>
Branch: <BRANCH_NAME>
Status: ā REMOVED
šļø Cleanup:
ā Git worktree removed
ā Git branch deleted
ā Directory removed from trees/
ā No lingering processes
š Important Notes:
⢠Both the worktree AND branch '<BRANCH_NAME>' have been deleted
⢠This removal is PERMANENT and cannot be undone
⢠If you need this branch again, create a new one with: /git-simple:create_worktree_prompt <BRANCH_NAME>
⢠The new branch will start from your current HEAD
š Verification:
ā Worktree not in git worktree list
ā Branch not in git branch list
ā Directory trees/<BRANCH_NAME> removed
If any issues occurred during removal, include a warnings section:
ā ļø Warnings / Issues:
- Used --force flag to remove worktree (had uncommitted changes)
- Used -D flag to force delete branch (had unmerged changes)
If worktree was already partially removed or not found:
ā ļø Worktree Status:
- Worktree 'trees/<BRANCH_NAME>' was not found in git worktree list
- Directory may have been manually deleted
- Run 'git worktree prune' to clean up worktree metadata
š Cleanup Command:
git worktree prune
If orphaned directory exists after removal:
ā ļø Manual Cleanup Required:
- Directory trees/<BRANCH_NAME> still exists after git worktree remove
- This should not happen normally
- To manually remove, run from PROJECT_CWD:
rm -rf trees/<BRANCH_NAME>