From: D. Ben Knoble Date: Sat, 24 Oct 2026 13:35:17 GMT Subject: Re: [RFC] branch: delete gone-upstream branches only when proven merged into a named ref Message-ID: In-Reply-To: On Thu, Oct 22, 2026 at 1:54 PM Harald Nordgren wrote: > > Why do we need the `--into` at all? This message trimmed so much context that I had to visit lore to see what it replied to… …but I think you'll find the answer in the original mail, which discusses how --delete-merged works when the upstream branch is deleted (e.g., via GitHub's "automatically delete head branches" setting, which is useful to enable IMO). In that case, even though the branch was merged, the local topic is not a candidate for deletion (because we can't be sure about what happened to its upstream). So the proposal is originally either * add a modifier to --delete-merged that allows considering such topics * add a modifier to "git branch --delete" for the same To which I've suggested that either * delete-merged should be allowed to work in this case, possibly via a special syntax, modifier option, etc. * branch --delete should be allowed to filter branches, in which case we could even migrate some of --delete-merged into that form In hindsight, an *even more composable* interface would have been to teach --list mode how to filter the appropriate merged branches (which we could then add to for this RFC) and encourage git branch --list [filters] | xargs git branch -d possibly adding a -z option if needed (which my read of git-check-ref-format(1) suggests is unnecessary)? In which case --delete-merged could be something like git branch --list --merged-upstream=origin/main | xargs git branch -d where --merged-upstream= lists all branches whose upstream configuration is reachable from (and I suppose you might need "-D" in some cases, hence the --delete-merged --dry-run form today, which would be "just omit the pipe to xargs" in this version). And the delete-merged branch filter would still work, since --list takes pattern arguments! Hm. I'm starting more and more to feel like this is a missed opportunity. Rereading our docs for git-branch(1), I think what this RFC is looking for is git branch --list --merged=origin/main | xargs git branch -d which should already list (and then delete) local branches whose tip is reachable from origin/main. And it would be sure nice if that combined with --delete-merged, but since they are separate forms, more work is needed. If we had the --merged-upstream filter, we'd simply do git branch --list --merged{,-upstream}=origin/main | xargs git branch -d :) -- D. Ben Knoble