A VS Code extension that makes it easy to delete all Git branches that have already been merged into your main branch. Keep your repository clean and organized by removing stale branches with a single command.
Features
Automatic Detection: Identifies all local branches that have been merged into main or master
Safe Deletion: Prevents accidental deletions with a confirmation dialog
User Selection: Choose which branches to delete before confirming
Multi-Repo Support: Works with multiple Git repositories in your workspace
Progress Tracking: Visual progress indication while deleting branches
Branch Protection: Automatically excludes your current branch and the main branch from deletion
Requirements
VS Code version 1.109.0 or higher
Git extension (built-in to VS Code)
A Git repository in your workspace
Usage
Open the Command Palette with Ctrl+Shift+P (or Cmd+Shift+P on macOS)
Search for and select "Cleanup: Delete Merged Branches"
A list of merged branches will appear - select which ones you want to delete
Confirm the deletion when prompted
The extension will delete the selected branches and show a completion message
How It Works
The extension:
Connects to VS Code's built-in Git extension
Fetches the latest branch information from your repository
Compares each local branch against the main branch using git merge-base
Identifies branches that have been fully merged
Presents them to you for selection and deletion
Known Issues
Branch detection relies on the repository being up-to-date. Run git fetch manually before executing the command if you haven't recently synced with remote.
The extension uses git branch -d which only deletes fully merged branches. Force deletion is not supported for safety reasons.
Extension Settings
This extension contributes the following settings:
cleanupMergedBranches.mainBranches: An array of branch names to consider as the main branch when checking for merged branches. Default: ["main", "master"]
cleanupMergedBranches.confirmDeletion: When true, shows a selection prompt and confirmation dialog before deleting branches. When false, deletes all merged branches without prompting. Default: true
cleanupMergedBranches.autoCleanup: When true, automatically cleanup merged branches whenever the git index changes (e.g., after git fetch, git pull, or git merge) or when you switch branches. Default: false
cleanupMergedBranches.silent: When true, suppresses all informational and warning messages. Error messages are still shown. Useful with autoCleanup for completely silent background cleanup. Default: false
Example Configuration
To use a different main branch name (e.g., develop) and enable automatic cleanup with silent mode: