Back to skills
SKILL.md
310 Clean Gone Branches 174bbd58
ASecurityClean up local branches deleted from remote
- 9 stars
- 0 votes
- 0 copies
- 0 views
- Added October 11, 2026
Security analysis
100/100Pro scans all 2 files and shows the line behind each finding
npx -y skills add tools-only/X-Skills --skill 310-clean-gone-branches_174bbd58 --agent claude-codeAre you the author of 310 Clean Gone Branches 174bbd58?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/tools-only-310-clean-gone-branches-174bbd58)---
description: Clean up local branches deleted from remote
---
# Clean Gone Branches
Remove local git branches that have been deleted from remote (marked as [gone]).
## Instructions
Run the following commands in sequence:
1. **Update remote references:**
```bash
git fetch --prune
```
2. **View branches marked as [gone]:**
```bash
git branch -vv
```
3. **List worktrees (if any):**
```bash
git worktree list
```
4. **Remove worktrees for gone branches (if any):**
```bash
git branch -vv | grep '\[gone\]' | awk '{print $1}' | sed 's/^[*+]*//' | while read -r branch; do
worktree=$(git worktree list | grep "\[$branch\]" | awk '{print $1}')
if [ -n "$worktree" ]; then
echo "Removing worktree: $worktree"
git worktree remove --force "$worktree"
fi
done
```
5. **Delete gone branches:**
```bash
git branch -vv | grep '\[gone\]' | awk '{print $1}' | sed 's/^[*+]*//' | xargs -I {} git branch -D {}
```
Report the results: list of removed worktrees and deleted branches, or notify if no [gone] branches exist.Files in this skill
- README.md
- skill.md
Attribution
Comments
Loading comments…