I use git on a corporate network that requires a proxy to access github.
I have set the proxy in .gitconfig and it works fine from the network.
When I am not in the office, I connect to the corporate network via VPN. Git works fine like that too.
If i disconnect from the VPN git cannot resolve the proxy (as expected), failing with fatal: unable to access '...': Could not resolve proxy: ....
Is there a way for git to only use the proxy if it needs to?
I don't want to have to keep editing the config depending on if the VPN is active.
In Rust, the cargo command can pull from github with zero config with or without the VPN active. It would be nice if git on windows could do the same.
Perhaps you could use a git alias to set and unset the proxy? (I know that you're technically still editing the config, but I can't think of a way you could do this automatically, as profiles rely on the file path.)
For example, to set the proxy with a setproxy alias:
git config --global alias.setproxy 'config --global http.proxy http://example-proxy'
And to unset using a noproxy alias:
git config --global alias.noproxy 'config --global --unset http.proxy'
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