git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Removing fully-merged branches

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 10, 2021, 01:41 UTC
Message-ID
<xmqqwnr2h4xn.fsf@gitster.g>
In-Reply-To
<DBAPR05MB7510441970BA87A456B8C0D8EC369@DBAPR05MB7510.eurprd05.prod.outlook.com>
Vojtěch Vladyka <Vojtech.Vladyka@velux.com> writes:
Show 6 quoted lines
> I know there are command chains doing this job usually starting
> with git branch --merged followed by grep and ending with git
> branch -d but my point is why such functionality isn't in git
> client already when he has all pieces of information already and
> ability to do all of that. Maybe I am missing some reason behind
> that but to me it looks like missing feature.

I think the primary reason behind it is because the way to "prune" (i.e. you gave a good outline yourself in your messaage) is trivially discoverable and people can do so with more flexibility than a hardcoded "remove every branch that does not have commits that does not exist in the $master branch". Add to it the fact that those who want to make it into a "native" feature haven't produced any usable design yet [*].

In my repository that is used to develop Git itself, for example, "remove all branches that are merged to 'master'" is not something I'd ever want to run, as it will lose all the maintenance tracks (it is a rule in this project that older maintenance branches are subset of the newer ones and the 'master' branch), and removing all topic branches that are merged to 'maint' would not get rid of as many stale topic branches that are already merged to 'master' and will never be merged down to 'maint' or older maintenance tracks, so for such a feature to be useful, I'd need to be able to express something like:

 - If a branch is not a topic branch (identifyable by having
   two-level names like vv/topic), do not touch it.
 - If a topic branch is based on 'maint' but not merged there yet,
   keep it.
 - If a topic branch is merged to 'master' and in a tagged version
   (identifyable by having a signed tag whose name does not end with
   -rcX), lose it.

So that a bugfix topic that has appeared in the last feature release can be kept to later be merged down to older maintenance tracks.

[Footnote]
 * As far as I remember, the message I am responding to might be the
   first to explicitly ask for such a feature.
Previous: Vojtěch VladykaNext: Vojtěch Vladyka
Message 2 of 3 in “Removing fully-merged branches”
  1. Vojtěch VladykaJun 9, 2021
  2. Junio C HamanoJun 10, 2021
  3. Vojtěch VladykaJun 10, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.