Is it possible to configure git to use a proxy only for specific domains?
I'd like to use our corporate proxy to access Github but leave it off for accessing our own internal git repos.
I'm using bower and it needs to require items both within our firewall and on github so I can't do this as a per project setting. It needs to be some kind of global configuration option. Any thoughts?
Setting the proxy for Gitgit config --global --add http. proxy http://USERNAME:PASSWORD@PROXY_ADDRESS:PROXY_PORT. git config --global --add https. proxy http://USERNAME:PASSWORD@PROXY_ADDRESS:PROXY_PORT.
You can do same in Windows. Add an environment variable 'no_proxy' with value of URLS_to_Ignore. Don't forget to start a new CMD shell. Or to get working in current CMD just set no_proxy=URLS_to_Ignore .
Now whenever you do anything with [email protected] , it will use the proxy automatically.
To add another possibility, you can define a proxy through the git config http.proxy.
git config --global http.proxy http://mydomain\\myusername:mypassword@myproxyserver:proxyport But what is really neat is, starting git1.8.5 (October 2013), you can set http settings per url.
The "http.*" variables can now be specified per URL that the configuration applies.
For example,
[http] sslVerify = true [http "https://weak.example.com/"] sslVerify = false would flip
http.sslVerifyoff only when talking to that specified site.
See commit d4770964d5:
$ git config --bool --get-urlmatch http.sslVerify https://good.example.com true $ git config --bool --get-urlmatch http.sslVerify https://weak.example.com false With only
<section>specified, you can get a list of all variables in the section with their values that apply to the given URL. E.g
$ git config --get-urlmatch http https://weak.example.com http.sslverify false All the details are in commit 6a56993b:
http.<url>.*:: Any of the http.* options above can be applied selectively to some urls.
For a config key to match a URL, each element of the config key is compared to that of the URL, in the following order:
https in https://example.com/).example.com in https://example.com/).8080 in http://example.com:8080/).repo.git in https://example.com/repo.git). user in https://[email protected]/repo.git)The list above is ordered by decreasing precedence; a URL that matches a config key's path is preferred to one that matches its user name.
For example, if the URL ishttps://[email protected]/foo/bara config key match ofhttps://example.com/foowill be preferred over a config key match ofhttps://[email protected].All URLs are normalized before attempting any matching (the password part, if embedded in the URL, is always ignored for matching purposes) so that equivalent urls that are simply spelled differently will match properly.
Environment variable settings always override any matches.
The urls that are matched against are those given directly to Git commands.
This means any URLs +visited as a result of a redirection do not participate in matching.
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