Skip to content

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

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 mockMockRepository 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
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