clean-branches
SolidDelete local branches whose remote has been deleted ([gone]), including their worktrees. Use for branch cleanup after merging PRs.
AI & Automation 775 stars
114 forks Updated today AGPL-3.0
Install
Quality Score: 83/100
Stars 20%
Recency 20%
Frontmatter 20%
Documentation 15%
Issue Health 10%
License 10%
Description 5%
Skill Content
# Clean Branches
Remove local branches that have been deleted on the remote (marked `[gone]`), including any associated git worktrees.
## Steps
1. **Fetch and prune remote refs:**
```bash
git fetch --prune
```
2. **List branches to identify [gone] status:**
```bash
git branch -v
```
Branches with a `+` prefix have associated worktrees that must be removed before deletion.
3. **List worktrees for reference:**
```bash
git worktree list
```
4. **Remove worktrees and delete [gone] branches:**
```bash
git branch -v | grep '\[gone\]' | sed 's/^[+* ]//' | awk '{print $1}' | while read branch; do
echo "Processing branch: $branch"
worktree=$(git worktree list | grep "\\[$branch\\]" | awk '{print $1}')
if [ ! -z "$worktree" ] && [ "$worktree" != "$(git rev-parse --show-toplevel)" ]; then
echo " Removing worktree: $worktree"
git worktree remove --force "$worktree"
fi
echo " Deleting branch: $branch"
git branch -D "$branch"
done
```
5. **Report** which branches and worktrees were removed. If none were `[gone]`, say no cleanup was needed.
Details
- Author
- kdlbs
- Repository
- kdlbs/kandev
- Created
- 8 months ago
- Last Updated
- today
- Language
- Go
- License
- AGPL-3.0
Integrates with
Similar Skills
Semantically similar based on skill content — not just same category
AI & Automation Featured
clean-gone-branches
This skill should be used when user asks to "clean gone branches", "remove deleted local branches", "prune branches removed from remote", or explicitly invokes "clean-gone-branches".
1,141 Updated today
fcakyon AI & Automation Listed
gh-clean-branches
Prune stale local branches — detects branches whose remote is gone and merged feature branches still hanging around. Shows a combined list for confirmation before deleting anything.
0 Updated 1 weeks ago
seansmithworks Code & Development Listed
clean-gone-branches
Remove local git branches whose configured upstream is marked [gone], including associated worktrees.
3 Updated today
dceoy