From: Eric Sunshine Date: Wed, 21 Oct 2026 08:06:48 GMT Subject: Re: [PATCH v2 2/2] worktree: reap ephemeral branches created by "worktree add" Message-ID: In-Reply-To: On Wed, Oct 21, 2026 at 3:40 AM Jason Newton wrote:> > --detach and an ephemeral branch differ while the worktree exists. > > --detach leaves HEAD with no branch, so status, push, rename, > upstream, and symbolic-ref have nothing to name. An ephemeral > branch is a normal refs/heads/ ref for the life of the worktree. > Commits go on it, and another ref can point at them before > "worktree remove" deletes that branch. > > Deleting the branch that "worktree add " creates today > would change the default, so this has to be opt-in. That opt-in > is not --detach: the worktree stays on a branch until removal. > > These worktrees might be minutes or they might go on for months; > either way they should be easy to use and not require flags to assist > in the majority of common case behaviors, moreover detached feels > ike a degraded halfway state, frequently allowing a gotcha to strike or > a loss of a safety like a gc based reap. > > "git worktree remove" does not delete whatever branch a worktree > has checked out. It deletes a branch only when this "git worktree > add" created it by DWIM (the final component of ) and recorded > that in worktrees//owned-branch. > > A branch named with -b/-B, a branch that already existed, and a > detached HEAD are not owned and are not removed. A worktree created > by an older Git has no marker, so removing it still leaves its > branch in place. > > "Unconditional" in the commit means that this one owned branch is > deleted even if it has unmerged commits. --keep-branch turns that > off. "git branch " before removal keeps the commits on > an ordinary branch; only the owned ref is deleted. > > The call that changes is "git worktree add " with no branch, > followed by "git worktree remove". A caller who wants that branch > to outlive the worktree already has a spelling this series does not > touch: "git worktree add -b ", or "git worktree add > ". --detach still creates no branch, so it is not > the same state while the worktree exists. > > Ownership is written only when the worktree is created, so I'll confirm > an older worktree still has no marker after an upgrade. The branch stays. > Upgrading does not mark a worktree you already have so no upgrade > headaches are expected. Feeding a reviewer's comments into an agent and pasting its LLM-generated response into an email is not a good way to convince project stakeholders that the submission has value. If you can't explain its value in concrete terms in your own words, then you're going to have a hard time eliciting any responses or additional reviewer feedback.