Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Git Branch CleanNew to Visual Studio Code? Get it now.
Git Branch Clean

Git Branch Clean

FENG QIN

|
2 installs
| (1) | Free
检查并清理长期未处理的本地 Git 分支。
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Git Branch Clean

English | 简体中文

Git Branch Clean is a VS Code extension for finding and safely cleaning up stale local Git branches in the current workspace.

Install from Visual Studio Marketplace:

Open Git Branch Clean in Marketplace

Open the link, click Install, and start using the command in VS Code.

It checks local branches whose latest commit age reaches the configured threshold, shows whether each branch has already been merged into your configured main branches, and lets you safely delete selected branches with git branch -d.

Features

  • Run from the Command Palette: Git Branch Clean: 检查过期分支
  • Default keybinding:
    • macOS: Cmd+Alt+B
    • Windows/Linux: Ctrl+Alt+B
  • Checks local branches only. Remote branches are not scanned or deleted.
  • Supports multiple main branch names, separated by commas. Default: main,master
  • Configurable stale threshold in hours. Default: 720 hours, equal to 30 days.
  • Merged stale branches are preselected in Quick Pick, so pressing Enter safely deletes them.
  • Unmerged stale branches require a second Quick Pick confirmation before deletion.
  • Supports include and exclude branch patterns with * wildcards.
  • Uses safe deletion only: git branch -d -- <branch>. It never uses git branch -D.

Settings

{
  "gitBranchCleanup.mainBranch": "main,master",
  "gitBranchCleanup.staleHours": 720,
  "gitBranchCleanup.includeBranchPatterns": "chore/*,feature/*",
  "gitBranchCleanup.excludeBranchPatterns": "chore/keep-*"
}

gitBranchCleanup.mainBranch

Comma-separated main branch names used to determine whether a local branch has been merged.

Default:

"main,master"

gitBranchCleanup.staleHours

How many hours since the latest commit before a local branch is considered stale.

Default:

720

gitBranchCleanup.includeBranchPatterns

Comma-separated branch patterns to include in the scan. Supports *.

Default:

"*"

gitBranchCleanup.excludeBranchPatterns

Comma-separated branch patterns to exclude from the scan. Supports *.

Default:

""

Cleanup Behavior

The extension only runs Git's safe delete command:

git branch -d -- <branch>

If Git refuses to delete a branch, usually because it is not considered fully merged, the extension reports the failure details. It does not force-delete branches.

Development

pnpm install
pnpm run compile
pnpm test
pnpm run package:vsix

Press F5 in VS Code to start an Extension Development Host for manual testing.

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