Finishing and removing worktrees
Remove the worktrees whose work is merged in one reviewed step, and any other with a backup of what it held.
A worktree whose work is in its base has done its job.
Finishing
Repository ▸ Clean Up Worktrees… (⌃⇧⌘K) reviews every linked worktree in one confirmation and lists, for each, whether it will be removed or why it is skipped. A worktree qualifies when it is clean and unlocked, on a local branch, and all of its own commits are in its base — merged or squashed in. Its folder goes, ignored files with it, and its branch is deleted with a backup in Recovery.
Repository ▸ Finish Worktree… (⌃⇧⌘D) does the same for one worktree, and a row offers it once its work is in. Both run in the main worktree’s window, so no window removes the folder it is showing. Anything that changed after the confirmation, such as a new commit or an agent starting work, is skipped and said so.
A worktree on a detached HEAD, as Codex leaves its own, needs Create Branch Here… first.
Removing
Remove Worktree…, in a row’s menu, removes any other linked worktree, merged or not, and says first what goes with the folder:
- Uncommitted changes, staged, unstaged and untracked, are saved to Discarded Changes in Recovery, and any worktree can put them back.
- Commits on no branch, on a detached HEAD, are saved as a deleted
branch named
worktree/‹folder›, which restoring a deleted branch brings back. - Ignored files are not saved. They go with the folder.
With something to save, the button reads Save to Recovery and Remove. Innesta stops before deleting anything, and says why, when the worktree is locked, busy in another window, in the middle of a merge or rebase, holds initialised submodules or another repository, or has an agent working or waiting in it. The main worktree and the window’s own are never offered.