git-worktree-remove
FeaturedSafely remove a git worktree with branch cleanup and safety checks
AI & Automation 5,772 stars
755 forks Updated today CC-BY-SA-4.0
Install
Quality Score: 96/100
Stars 20%
Recency 20%
Frontmatter 20%
Documentation 15%
Issue Health 10%
License 10%
Description 5%
Skill Content
# Git Worktree Remove
Safely remove a single git worktree with branch cleanup, merge verification, and database branch teardown.
**Core principle:** Safety checks first, then clean removal of worktree + branch + DB resources.
**Part of:** [Worktree Lifecycle Suite](../../commands/git-worktree.md) | [`/git-worktree`](../../commands/git-worktree.md) | [`/git-worktree-status`](../../commands/git-worktree-status.md) | [`/git-worktree-clean`](../../commands/git-worktree-clean.md)
## Process
1. **Validate Target**: Identify worktree to remove
2. **Safety Check**: Protect main/develop branches
3. **Check Merge Status**: Warn if branch has unmerged changes
4. **Check Uncommitted Changes**: Warn if worktree has dirty state
5. **Remove Worktree**: `git worktree remove`
6. **Delete Local Branch**: `git branch -d` (or `-D` with confirmation)
7. **Delete Remote Branch**: `git push origin --delete` (with confirmation)
8. **Database Cleanup Reminder**: Suggest DB branch deletion if applicable
9. **Prune References**: `git worktree prune`
## Safety Checks
### Protected Branches
```bash
# Never remove worktrees for these branches (configurable)
PROTECTED_BRANCHES="main master develop staging production"
if echo "$PROTECTED_BRANCHES" | grep -qw "$BRANCH"; then
echo "BLOCKED: Cannot remove worktree for protected branch '$BRANCH'"
echo "Protected branches: $PROTECTED_BRANCHES"
exit 1
fi
```
### Uncommitted Changes
```bash
cd "$WORKTREE_PATH"
if [ -n "$(git status --porcelain)" ]...
Details
- Author
- FlorianBruniaux
- Repository
- FlorianBruniaux/claude-code-ultimate-guide
- Created
- 7 months ago
- Last Updated
- today
- Language
- Python
- License
- CC-BY-SA-4.0
Integrates with
Similar Skills
Semantically similar based on skill content — not just same category
AI & Automation Featured
git-worktree-clean
Clean up stale git worktrees with merged branch detection and disk usage report
5,772 Updated today
FlorianBruniaux AI & Automation Featured
git-worktree
Create isolated git worktrees for feature development without switching branches
5,772 Updated today
FlorianBruniaux Code & Development Listed
worktree-cleanup
Tear down a finished task's git worktree and branch once its PR is merged or closed. Use when a task is done, a PR was merged/closed, or the user asks to clean up / remove / prune worktrees or stale branches. Companion to the `worktree-new` skill; applies to whatever repository Claude is currently in.
0 Updated 4 weeks ago
Enverge-Labs