Skip to content

Deleting a worktree after merging a PR into a branch mixes the main branch with the worktree #8519

@MrSilco

Description

@MrSilco

Description

After merging a PR that was created from a worktree (test_1) into a branch, a button will appear for deleting the brach and its remote. Clicking on that deletes the branch and its remote that was associated with the worktree but mixes the main branch and the worktree's folder together somehow.

git worktree list

/Volumes/Work/git-projects/own/sandbox c598839 [develop]
/Volumes/Work/git-projects/own/sandbox.worktrees/test_1 1858442 [main]

Steps to Reproduce

  • Create a main branch
  • Create a develop branch from main
  • Create a worktree from develop
  • Switch to the worktree then submit some changes and push to origin
  • Create a PR from the worktree
  • Merge the PR into the develop branch
  • Click on the delete branch button
  • Delete the branch (worktree this time) and its remote
  • Run this command: git worktree list
  • The worktree folder still exists and somehow the main branch is associated with it
  • For restoring the main branch original behaviour we have to delete the worktree folder manually then prune the worktree that's folder doesn't exist anymore with this command git worktree prune -v

Expected Behavior

The worktree folder, its branch & remote are deleted and no previous branches are associated with the deleted worktree's folder.

Actual Behavior

The deleted worktree's folder remains on disk & associated with the main branch.

Environment

VS Code version: 1.109.3
Extension version: 0.128.0
OS: macOS 26.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions