Subject: Re: [PATCH v9 3/5] branch: add --prune-merged <remote>

From: Phillip Wood <[email-masked]>
Date: Thu, 21 May 2026 10:46:17 +0100

Hi Harald

A couple more thoughts ...

On 18/05/2026 16:27, Phillip Wood wrote:
> On 13/05/2026 20:34, Harald Nordgren via GitGitGadget wrote:
>> From: Harald Nordgren <[email-masked]>
>>
>> Delete the local branches that --forked <remote> would list, but
>> only those whose tip is reachable from their configured upstream
>> remote-tracking branch (branch.<name>.merge): the work has already
>> landed on the upstream it tracks, so the local copy is no longer
>> needed.

While we want to clean up topic branches, we want to avoid cleaning up 
branches like "master" which follow an upstream branch and therefore 
look like they've been merged straight after they've been pulled. So I 
think as well as checking that the local branch is merged into its 
upstream branch, we want to check that the local branch is not pushed to 
the upstream branch i.e. that branch@{upstream} != branch@{push}. That 
should also avoid deleting newly created topic branches that match their 
upstream (I think that's probably less likely to happen in practice as 
I'd expect the branch to be checked out and therefore protected against 
deletion).

Also as this is a destructive operation (there is no way to restore a 
deleted branch and its reflog) it would be good to have a --dry-run option.

Thanks

Phillip