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.
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>.skipDefaultUpdateIf true, this remote will be skipped by default when updating using git-fetch[1] or the
updatesubcommand 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
git config remotes.usual "origin upstream qa maint vendor and so forth"
git remote update usual
if it's easy to list the usual suspects once up front. To scan your remote urls you can
git config --get-regexp remote\\..*\\.url
and a little light sed'ing will get you the remote names that have whatever pattern you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With