Search code examples
gitgit-fetch

git fetch blacklist remote


Is there a way to make git fetch --all, or alternatively some other flag to git fetch, to not fetch from one remote?

I know there is the git fetch --multiple foo bar baz but I am looking for something more along the lines of git fetch --exclude remote_rarely_fetched_from_needs_vpn.

Otherwise I have to wait for the command to time out from failing to establish a network connection to that remote.

Alternatively, it would work for my case if I can fetch from all remotes with hostname matching github.com, but I am interested in seeing all options, if any.


Solution

  • jthill's answer got me on the right track. I managed to find this piece of text in the documentation for git remote:

    update

    Fetch updates for a named set of remotes in the repository as defined by remotes.<group>. If a named group is not specified on the command line, the configuration parameter remotes.default will be used; if remotes.default is not defined, all remotes which do not have the configuration parameter remote.<name>.skipDefaultUpdate set to true will be updated.

    Digging through the git config documentation, I found the option that does exactly what I need:

    remote.<name>.skipDefaultUpdate

    If true, this remote will be skipped by default when updating using git-fetch[1] or the update subcommand of git-remote[1].

    To set this option on my repo, I simply do this:

    git config remote.remote_rarely_fetched_from_needs_vpn.skipDefaultUpdate true