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

Re: [Feature Request] Allow batch removal of remotes with 'git remote remove'

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 22, 2025, 16:23 UTC
Message-ID
<xmqqed0uyg0i.fsf@gitster.g>
In-Reply-To
<20250122030832.GA3322144@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 25 quoted lines
> On Wed, Jan 22, 2025 at 02:24:38AM +0000, brian m. carlson wrote:
>
>> Because `git remote remove` will remove remote-tracking branches and
>> their reflogs, we typically will want to do that all at once in a single
>> ref transaction, and hence in one command.  Not doing so performs very
>> poorly (as does, notably `git remote rename`[0]) when all of the refs are
>> packed.  If you have a large number of remotes to delete and a large
>> number of total refs, this will perform really badly indeed, since the
>> operation of rewriting the packed-refs file becomes quadratic.
>> 
>> The removal of the remote-tracking branches is also the reason that
>> editing the config isn't sufficient, either.
>
> I think the config update is probably quadratic, too (in the number of
> remotes). Each one is going to rewrite the whole config file, minus its
> matching section. But a "remove" operation that took multiple remotes
> could do it all in a single pass.
>
> If somebody does implement "remote remove" that takes multiple names, I
> hope they'll refactor to do all of the operations in a single pass, and
> not just loop on builtin/remote.c:rm() internally.
>
> Probably git-config could stand to learn similar tricks, too. There is
> "--remove-section", but I don't think you can pass multiple sections
> (and it's likewise quadratic).

Thanks for bringing up the performance aspect and where the problem lies in the current implementation.

Previous: Jeff KingNext: Patrick Steinhardt
Message 7 of 8 in “[Feature Request] Allow batch removal of remotes with 'git remote remove'”
  1. Christian Fredrik JohnsenJan 20, 2025
  2. Emily ShafferJan 21, 2025
  3. D. Ben KnobleJan 21, 2025
  4. Junio C HamanoJan 21, 2025
  5. brian m. carlsonJan 22, 2025
  6. Jeff KingJan 22, 2025
  7. Junio C HamanoJan 22, 2025
  8. Patrick SteinhardtJan 22, 2025

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.