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 21, 2025, 22:38 UTC
Message-ID
<xmqqikq7yepr.fsf@gitster.g>
In-Reply-To
<CALnO6CAEaOUNwMpOTF8wKVd7LAv+UiU5W62ZCBc0U-K_JhHU-g@mail.gmail.com>
"D. Ben Knoble" <ben.knoble@gmail.com> writes:
Show 11 quoted lines
>> Hi Christian, is there a reason why opening up the config (`vim
>> .git/config` or `git config edit --local`) and batch-deleting remotes
>> from there is undesirable? If this is a solution you believe only
>> power users need, then I'd posit a power user can both list all
>> remotes *and* remove the offending ones in a single editor pass,
>> rather than having to run multiple `git remote` commands, anyway.
>
> I'd posit a power user can also do something a bit like (Zsh with GNU
> or FreeBSD xargs) `print -N my remotes to delete | xargs -0n1 git
> remote remove`, or (portably) `for remote in my remotes to delete; do
> git remote remove "$remote"; done`.

Having to run "git remote remove" 1000 times for 1000 remotes you happen to have may not be the best use of machine cycles. I'd have to think about "git config edit --local". If you have 1000 remotes, the chance of mistakes may be too big, as it is likely that you would not notice if you removed unrelated things by accident. Besides, the remote-tracking branches are left behind if you only used "git config edit --local".

> I couldn't find a comparable command beyond `git branch --delete`,
> which _does_ take multiple branches.

I do not offhand think of a reason why it is a bad idea to let "git remote remove <name>" take more than one remote names (i.e. making it "git remote remove <name>..."). Even though it may not help if you have 1000 remotes and want to remove all of them in one go, at least your xargs command line invocation would become less wasteful.

Thanks.
Previous: D. Ben KnobleNext: brian m. carlson
Message 4 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.