Skip to content
| Marketplace
Sign in
Visual Studio Code>SCM Providers>Git Stale Branch CleanerNew to Visual Studio Code? Get it now.
Git Stale Branch Cleaner

Git Stale Branch Cleaner

Sabeen

|
1 install
| (0) | Free
Scan merged/stale branches and safely delete them with an interactive UI
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Git Branch Cleaner

A VS Code extension that scans your local Git branches, identifies merged and stale branches, and lets you safely delete them through an interactive UI.


Features

  • Merged branch detection — finds branches already merged into your current HEAD
  • Stale branch detection — flags branches with no commits in the last N days (configurable)
  • Protected branch filtering — never suggests deleting main, master, dev, develop, staging, production, or your custom protected branches
  • Unpushed commit guard — skips branches with local commits not yet pushed to a remote
  • Interactive QuickPick UI — checkbox-style multi-select with branch status details
  • Safe delete by default — uses git branch -d (refuses to delete unmerged branches)
  • Auto-fetch before scan — optionally runs git fetch --prune to keep branch state fresh

Commands

Open the Command Palette (Cmd+Shift+P / Ctrl+Shift+P) and run:

Command Description
Git Branch Cleaner: Scan Branches Interactive scan — pick which branches to delete
Git Branch Cleaner: Clean Branches (Auto-select Safe) Auto-selects all safe-to-delete branches

Settings

Setting Default Description
gitBranchCleaner.protectedBranches [] Additional branches to protect (added to built-in defaults)
gitBranchCleaner.staleDaysThreshold 30 Days of inactivity before a branch is considered stale
gitBranchCleaner.autoFetchBeforeScan true Run git fetch --prune before scanning
gitBranchCleaner.defaultRemote "origin" Default remote name for remote operations

Example settings.json

{
  "gitBranchCleaner.protectedBranches": ["hotfix", "release/v2"],
  "gitBranchCleaner.staleDaysThreshold": 60,
  "gitBranchCleaner.autoFetchBeforeScan": false
}

Safety Rules

A branch will never be suggested for deletion if it is:

  • The currently checked-out branch
  • A protected branch (built-in or user-configured)
  • A branch with unpushed local commits
  • An active branch with no merge or staleness issues

Built-in Protected Branches

The following branches are always protected:

main, master, dev, develop, staging, production, release

Project Structure

src/
├── extension.ts      # Entry point — activates extension, registers commands
├── git.ts            # Low-level Git command executor (child_process wrappers)
├── branchScanner.ts  # Branch analysis engine (merged, stale, safety checks)
├── ui.ts             # VS Code UI layer (QuickPick, dialogs, notifications)
├── config.ts         # Reads VS Code settings
└── types.ts          # Shared TypeScript interfaces

Development

# Install dependencies
npm install

# Compile TypeScript
npm run compile

# Watch mode (auto-recompile on save)
npm run watch

# Press F5 in VS Code to launch the Extension Development Host

License

MIT

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft