← 返回首页
Remove leftover branch git config when deleting local branches by Copilot · Pull Request #8832 · microsoft/vscode-pull-request-github · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

Remove leftover branch git config when deleting local branches#8832

Draft
alexr00 with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-delete-local-branches
Draft

Remove leftover branch git config when deleting local branches#8832
alexr00 with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-delete-local-branches

Conversation

Copilot AI commented Jul 7, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

The "Delete local branches and remotes" command (pr.deleteLocalBranchesNRemotes) listed branches that no longer exist. getBranchDeletionItems builds its picklist from .git/config, and stale [branch "<name>"] sections (left behind when a branch is deleted out-of-band) keep those branches appearing.

Changes

  • deleteBranches config cleanup — after unsetting the PR metadata keys, deleteConfig now also strips any remaining branch.<name>.* entries. This happens in the existing sequential config step (config ops can't be parallelized), scoped to the exact branch prefix so other branches/remotes are untouched, and logs rather than aborts on failure.
  • Test mock — MockRepository gains unsetConfig, and deleteBranch now throws a realistic git "not found" error (with stderr) for missing branches.
  • Tests — cover cleanup for both an existing branch and an already-deleted branch with stale config.
if (this.repository.unsetConfig) { const prefix = `branch.${branch}.`; const remaining = (await this.repository.getConfigs()).filter(config => config.key.startsWith(prefix)); for (const config of remaining) { await this.repository.unsetConfig(config.key); } }

Note: the electron test runner could not execute in the sandbox (VS Code download is network-blocked); tests type-check and the cleanup logic was verified in isolation.

Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issue with displaying deleted local branches Remove leftover branch git config when deleting local branches Jul 7, 2026
Copilot AI requested a review from alexr00 July 7, 2026 10:21
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Delete local branches" is showing branches that have already been deleted

2 participants

Footer

© 2026 GitHub, Inc.