Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Cleanup merged branchesNew to Visual Studio Code? Get it now.
Cleanup merged branches

Cleanup merged branches

Heris IT

|
6 installs
| (1) | Free
Cleanup merged branches
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Cleanup Merged Branches

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

  1. Open the Command Palette with Ctrl+Shift+P (or Cmd+Shift+P on macOS)
  2. Search for and select "Cleanup: Delete Merged Branches"
  3. A list of merged branches will appear - select which ones you want to delete
  4. Confirm the deletion when prompted
  5. The extension will delete the selected branches and show a completion message

How It Works

The extension:

  1. Connects to VS Code's built-in Git extension
  2. Fetches the latest branch information from your repository
  3. Compares each local branch against the main branch using git merge-base
  4. Identifies branches that have been fully merged
  5. 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:

{
  "cleanupMergedBranches.mainBranches": ["main", "master", "develop"],
  "cleanupMergedBranches.autoCleanup": true,
  "cleanupMergedBranches.confirmDeletion": false,
  "cleanupMergedBranches.silent": true
}

This enables hands-off cleanup that runs silently after fetch/pull/merge operations and branch switches.

Release Notes

1.0.0

  • Initial release
  • Automatic detection of merged branches
  • Safe branch deletion with confirmation
  • Multi-repository support
  • Uses VS Code's Git extension API
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft