Skip to content

Allow worktree removal when only a stale REBASE_HEAD remains - #7866

Merged
ymichael merged 2 commits into
mainfrom
bb/remove-unused-git-worktrees-thr_4j8pmfnkns
Nov 19, 2026
Merged

ymichael merged 2 commits into
mainfrom
bb/remove-unused-git-worktrees-thr_4j8pmfnkns

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

The worktree removal guard added in #6828 treated a REBASE_HEAD file in a linked worktree's git dir as an in-progress rebase. Git does not delete REBASE_HEAD when a rebase that stopped on a conflict finishes with git rebase --continue, so every checkout that once resolved a rebase conflict was permanently refused with "finish or abort the Git operation (REBASE_HEAD) first." Settings → Storage showed 16 such leftover worktrees (75 GB) on one machine, each with a clean git status and no rebase-merge/ or rebase-apply/ directory.

What changed

  • plugins/environment-git-worktree/host/worktree.ts: drop REBASE_HEAD from the operation markers. A rebase that is actually in progress is still detected through rebase-merge and rebase-apply. No wire, CLI, or config changes.

How you verified

  • New host-entry test runs a real conflicted rebase to completion, asserts REBASE_HEAD remains, and expects removal to succeed. It fails against the old guard with the same message seen in Storage settings, and passes with the change.
  • Reproduced the leftover directly with Git 2.54.0 (Apple Git-157).
  • pnpm exec turbo run test typecheck --filter=bb-plugin-environment-git-worktree: 157 tests pass.

AGENT GENERATED

🤖 Generated with Claude Code

ymichael and others added 2 commits November 19, 2026 15:04
Git leaves REBASE_HEAD in the worktree's git dir after a conflicted rebase
finishes, so the removal guard treated every such checkout as mid-rebase
and refused to retire it forever. An in-progress rebase is already caught
by rebase-merge and rebase-apply.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit 817177b into main Nov 19, 2026
35 checks passed
@ymichael
ymichael deleted the bb/remove-unused-git-worktrees-thr_4j8pmfnkns branch November 19, 2026 23:18
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