Skip to content

fix: prune git worktree tracking after orphaned worktree removal - #428

Merged
AmethystLiang merged 1 commit into
mainfrom
fix-worktree-delete
Apr 10, 2026
Merged

AmethystLiang merged 1 commit into
mainfrom
fix-worktree-delete

Conversation

@AmethystLiang

Copy link
Copy Markdown
Contributor

Summary

  • When removing an orphaned worktree, git worktree remove fails but the directory gets cleaned up via rm. Without a subsequent git worktree prune, git's internal tracking (.git/worktrees/<name>) remains stale — git worktree list continues to show the entry and the branch stays locked, preventing other worktrees from checking it out.
  • Adds git worktree prune after the rm in both the IPC worktrees:remove handler and OrcaRuntimeService.removeWorktree().
  • Adds a test verifying the prune call is made when removing an orphaned worktree.

Test plan

  • New unit test: prunes git worktree tracking when removing an orphaned worktree
  • Manually reproduce an orphaned worktree (delete the directory but not the git tracking), then remove via Orca — verify git worktree list no longer shows the stale entry

When removing an orphaned worktree, `git worktree remove` fails but the
directory is cleaned up via `rm`. Without a subsequent `git worktree prune`,
git's internal tracking remains stale — `git worktree list` continues to
show the entry and the branch stays locked. Add `git worktree prune` after
the rm in both the IPC handler and OrcaRuntimeService to fix this.
@AmethystLiang
AmethystLiang merged commit de36c6b into main Apr 10, 2026
1 check passed
@AmethystLiang
AmethystLiang deleted the fix-worktree-delete branch April 10, 2026 00:46
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…blyai#428)

When removing an orphaned worktree, `git worktree remove` fails but the
directory is cleaned up via `rm`. Without a subsequent `git worktree prune`,
git's internal tracking remains stale — `git worktree list` continues to
show the entry and the branch stays locked. Add `git worktree prune` after
the rm in both the IPC handler and OrcaRuntimeService to fix this.
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.

1 participant