wt remove <branch> on a worktree whose HEAD has since been detached deletes the branch, leaves the worktree, and exits 0 reporting success.
Worktrees go detached routinely — Codex creates one per session, and 0.72.0's own release notes say so. Any of those that started life on a branch is now in this state.
Repro
git init -b main repo && cd repo
git commit --allow-empty -m init
wt switch -c feature
git -C ../repo.feature checkout --detach
cd ../repo
wt remove feature --yes --foreground; echo "exit=$?"
git worktree list
Actual
○ No worktree found for branch feature
✓ Removed branch feature (same commit as main, _)
exit=0
/tmp/…/repo efb554a [main]
/tmp/…/repo.feature efb554a (detached HEAD)
The branch is gone, the worktree and its registration are still there, and the
command reported success. Nothing in the output says a removal was skipped: the ○
line reads as information, the ✓ line reads as the result, and a script checking
the exit code sees a clean run.
Expected
Either remove the worktree (it is the one wt switch -c feature created, and
wt remove <path> removes it happily), or refuse — but do not delete the branch and
report success while the worktree stays behind. The failing half is silent, so the
caller learns about it the next time something walks git worktree list.
Notes
wt remove <branch>on a worktree whose HEAD has since been detached deletes the branch, leaves the worktree, and exits 0 reporting success.Worktrees go detached routinely — Codex creates one per session, and 0.72.0's own release notes say so. Any of those that started life on a branch is now in this state.
Repro
Actual
The branch is gone, the worktree and its registration are still there, and the
command reported success. Nothing in the output says a removal was skipped: the
○line reads as information, the
✓line reads as the result, and a script checkingthe exit code sees a clean run.
Expected
Either remove the worktree (it is the one
wt switch -c featurecreated, andwt remove <path>removes it happily), or refuse — but do not delete the branch andreport success while the worktree stays behind. The failing half is silent, so the
caller learns about it the next time something walks
git worktree list.Notes
wt remove <path>on the same worktree works on both versions, so this is thebranch→worktree lookup, not detached removal itself. Cannot remove detached head worktrees #1661 / fix: allow removing detached HEAD worktrees from picker #1665 fixed the picker
path in 0.71.0-and-earlier; this is a different one.
git 2.50.1, Linux. Repro above runs under a scratch
HOMEwith no user config and norepo hooks, so nothing local is involved.