Keep your local git repositories clean by automatically identifying and removing branches that no longer exist on the remote server.
✨ Smart Detection - Accurately identifies stale local branches using git tracking information 🛡️ Safe by Default - Protects main, master, and your current branch from deletion 🔄 Auto-Scan - Configurable background scanning with smart notifications ⚙️ Flexible Scope - Work with all workspace repositories or just the active one 👁️ Identify Mode - Preview stale branches without deletion options
- Install the extension
- Click the 🌿 Prune button in the status bar
- Choose "Prune Stale Local Branches" or "Identify Stale Branches"
Access settings via Code → Preferences → Settings and search for "Git Branch Pruner":
gitBranchPruner.pruneAllWorkspaceRepos(default:false)true: Scan all git repositories in your workspacefalse: Only scan the repository containing your active file
gitBranchPruner.autoScanInterval(default:60minutes)- How often to automatically scan for stale branches
- Set to
0to disable auto-scanning - Minimum: 1 minute
gitBranchPruner.showNotifications(default:true)- Show notifications when branches are found or deleted
gitBranchPruner.identifyOnly(default:false)- When enabled, auto-scan notifications only show "Snooze" option
- Perfect for monitoring without accidental deletions
Click the 🌿 Prune button in your status bar to access:
- Prune Stale Local Branches - Find and delete stale branches
- Identify Stale Branches - Preview stale branches without deletion
Press Cmd+Shift+P (Mac) or Ctrl+Shift+P (Windows/Linux) and search for:
Git Branch Pruner: Show Prune MenuGit Branch Pruner: Prune Stale BranchesGit Branch Pruner: Prune Stale Branches (Active Repository Only)Git Branch Pruner: Show Pruneable Branches
When stale branches are found, you'll see a notification with options:
- Normal Mode: "Prune Now" and "Snooze" buttons
- Identify Only Mode: Only "Snooze" button (no deletion option)
Snooze options: 1 hour, 4 hours, or 24 hours
A branch is considered stale when:
- It has remote tracking configuration (
branch.BRANCH.remoteandbranch.BRANCH.merge) - The remote branch it was tracking no longer exists
- It's not a protected branch (main, master, or current branch)
- Protected Branches: Never deletes
main,master, or your current branch - Confirmation Required: Always asks before deleting branches (except in Identify Only mode)
- Detailed Logging: Check the "Git Branch Pruner" output panel for operation details
{
"gitBranchPruner.pruneAllWorkspaceRepos": true,
"gitBranchPruner.autoScanInterval": 60,
"gitBranchPruner.showNotifications": true,
"gitBranchPruner.identifyOnly": false
}{
"gitBranchPruner.autoScanInterval": 30,
"gitBranchPruner.identifyOnly": true,
"gitBranchPruner.showNotifications": true
}{
"gitBranchPruner.autoScanInterval": 0,
"gitBranchPruner.pruneAllWorkspaceRepos": false
}- Ensure you have stale local branches (branches that tracked remotes that were deleted)
- Check the "Git Branch Pruner" output panel for detailed information
- Try running
git fetch --prunemanually first
- Verify
autoScanIntervalis greater than 0 - Check that you're in a workspace with git repositories
- Look for error messages in the output panel
- The extension activates when VSCode starts
- Restart VSCode if the button doesn't appear
- Check that the extension is enabled in the Extensions panel
- Git must be installed and accessible in your system PATH
- VSCode workspace must contain git repositories
- Remote repositories should be accessible for accurate stale branch detection
Tip: Start with "Identify Stale Branches" to see what would be cleaned up before using the deletion features!