You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BranchPruner does not skip branches in use in worktrees #8043
The branch pruner automatically deletes branches that have been merged in to the default branch. But with it, it also tries to delete branches that are checked out in separate worktrees, causing the command to fail.
I also think this causes the some other command to fail, because it now already happened multiple times that when I switch to a branch, the last commits on that branch appear as staged, but as revert (so to undo those changes). This is something I have to check and confirm tho.
Version
GitHub Desktop: 2.1.0
Operating system: macOS 10.14.5 (18F132)
Steps to Reproduce
Open a terminal
Navigate to a repository
Create a new worktree git worktree add ../myrepo-2
I was hoping our worktrees wouldn't get caught up in these checks, but I guess we need to tweak or BranchPruner logic to be worktree-aware.
Because the branch pruner works in the background, we should tweak the flow to perform this additional work:
look for branches open in any worktrees for this repository
exclude those from any branch pruner work, to avoid the error reported by Git
#8006 adds some of our initial worktree support, and is currently under review. Once that's merged I plan to return to this and see what a potential solution might look like.
changed the title [-]BranchPruner does not consider branches in separate worktrees[/-][+]BranchPruner does not skip branches in use in worktrees[/+]on Jul 29, 2019
I have a fix for this ready with tests — PR #22004. Could a maintainer add the help wanted label so it doesn't get auto-closed?
The fix adds git worktree list --porcelain parsing and excludes branches checked out in linked worktrees from the pruner's deletion set. 6 new tests, full suite passing.
Activity
shiftkey commentedon Jul 29, 2019
@koenpunt thanks for this report!
I was hoping our worktrees wouldn't get caught up in these checks, but I guess we need to tweak or BranchPruner logic to be worktree-aware.
Because the branch pruner works in the background, we should tweak the flow to perform this additional work:
#8006 adds some of our initial worktree support, and is currently under review. Once that's merged I plan to return to this and see what a potential solution might look like.
[-]BranchPruner does not consider branches in separate worktrees[/-][+]BranchPruner does not skip branches in use in worktrees[/+]mesheets commentedon Feb 15, 2024
Referencing #907, which is for better support for worktrees
KRRT7 commentedon Apr 24, 2026
I have a fix for this ready with tests — PR #22004. Could a maintainer add the
help wantedlabel so it doesn't get auto-closed?The fix adds
git worktree list --porcelainparsing and excludes branches checked out in linked worktrees from the pruner's deletion set. 6 new tests, full suite passing.Sync with upstream/development (Electron 42, Copilot fixes, dependabo…