Skip to content
Back to skills

310 Clean Gone Branches 174bbd58

ASecurity

Clean up local branches deleted from remote

  • 9 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 11, 2026
toolsgobashgit

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned October 11, 2026

npx -y skills add tools-only/X-Skills --skill 310-clean-gone-branches_174bbd58 --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 310 Clean Gone Branches 174bbd58?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 310 Clean Gone Branches 174bbd58
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tools-only-310-clean-gone-branches-174bbd58/badge)](https://www.skillsdirectory.com/skills/tools-only-310-clean-gone-branches-174bbd58)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
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.md923 B
  • skill.md1.1 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…