Subject: Re: [PATCH] fetch: add fetch.pruneLocalBranches config

From: Johannes Sixt <[email-masked]>
Date: Tue, 5 May 2026 09:14:07 +0200

Am 04.05.26 um 00:39 schrieb Junio C Hamano:
> To break the feature down to make it easier to use by our users with
> various needs and workflows, we would benefit from having a
> collection of smaller features that can be composed, like these:
> 
>  * "git branch --forked <remote>" lists local branches that build on
>    something taken from <remote>s.  The option can be given multiple
>    times to make a union of the results from individual "--forked
>    <remote>".

Clearly, this version of --forked does something very different from the
option `--merged some_branch` that we already have.

> 
>    - <remote> may be a name of a remote, e.g., "origin" to mean all
>      the remote-tracking branches "refs/remotes/origin/*", 
> 
>    - <remote> may be "origin/master" to name a specific
>      remote-tracking branch.
> 
>    - There may be other handy things to cover with <remote>, like
>      "--all" that may act as if you listed all the available
>      <remote> on the command line.
> >  * "git branch --prune-merged <remote>..." is a short-hand for "git
>    branch -d $(git branch --forked <remote>...".

I don't understand this. The option includes the word "merged". Then I
interpret the command to prune only branches that have already been
merged into something (BTW, merged into what?), but as described, the
command removes all local branches that have been forked from some
(remote) branch.

> 
>  * "git fetch/pull --prune-merged <remote>" can trigger "git branch
>    --prune-merged <remote>" after "git fetch" successfully updates
>    the remote-tracking branches, which should be equivalent to what
>    you have here..

I think that the intended behavior is to call the equivalent of `git
branch --merged X | xargs git branch -d` for a suitable set of 'X' to be
determined by `git fetch`.

-- Hannes