Clean up a repository's finished branches with their worktrees, and put them back for 30 days
Clean up… on the Git page lists a repository’s local branches that can go, grouped by why: their commits are in the default branch, their merge request was merged with everything they hold, their thread is still open, or they look finished but hold work found nowhere else. Branches of open threads are never preselected, and a branch that would lose work, or whose agent is working, cannot be chosen. Nothing on the remote is touched.
Removing takes each branch with its worktree, one at a time, and Stop ends after the one in progress; the summary then names the branches it did not reach. A removed branch is kept for 30 days with its upstream setting: Removed, kept for 30 days puts it back. Its worktree’s folder does not come back.
Once a thread’s merge request merges, its Git tab offers to remove the thread’s branch and worktree, and afterwards to put the branch back. A thread whose branch was removed does not go back to it: its next message starts a new branch in a new worktree from the default branch, as a new thread does, and its composer says so until then. Put the branch back before that message and the thread works on it again. A worktree made outside the worktree location is not made again. The phone has the same clean-up on a repository’s page, and agents can read the plan and run it through a tool.