10

I almost always work behind a firewall and use an http proxy, which is set in my global git configuration. Now and then I'm stuck in a public location outside the firewall, and revert to a non-proxy lifestyle. This means telling my browser not to use the proxy, etc., etc., which I have to undo once I'm back safe and snug in a friendly location.

I want to do a single pull, or commit/push with git outside the firewall, but I don't want to delete the proxy setting from the configuration, because an hour from now I will just have to add it back again. I want to so something like

git -c http.proxy="" pull

or

git --unset http.proxy pull

so that I can just do the pull this one time without the proxy. But the first one results in error: Missing value for 'http.proxy' and the second is not a valid syntax.

So the question is:

How do I unset http.proxy for just one pull?

Jeff Snider
  • 750
  • 1
  • 6
  • 20
  • Can you set the `http_proxy` environment variable instead of using `http.proxy`? That way you could just `http_proxy="foo" git pull` instead... – Edward Thomson Feb 21 '14 at 17:56
  • For whatever reason in my installation git doesn't use the setting in that environment variable. – Jeff Snider Feb 21 '14 at 21:00
  • The `*_proxy` variables are weird in that they tend to lower-case scheme (but I always forget which program uses which case). Does it honor `HTTP_PROXY` or `http_PROXY` instead? – Edward Thomson Feb 21 '14 at 21:30
  • It does not seem to. I have resigned myself to using a pair of homemade scripts, git.set.proxy and git.unset.proxy, which do the obvious thing with the global config. – Jeff Snider Feb 22 '14 at 18:49
  • Possible duplicate of [How to temporarily disable git http proxy](http://stackoverflow.com/questions/19523903/how-to-temporarily-disable-git-http-proxy) – thdoan Nov 09 '16 at 14:31

1 Answers1

1

The Best solution for this would be to write two batch file with one proxy setting and other where you unset the proxy. Before the pull request you can run the batch file according to your need.

You can set the Git proxy using the below command in the git bash. Set for both HTTP and HTTPS proxy.

git config --global http.proxy http://username:password@proxy.server.com:8080
git config --global https.proxy http://username:password@proxy.server.com:8080

//Replace username with your proxy username
//Replace password with your proxy password
//Replace proxy.server.com with the proxy domain URL.
//Replace 8080 with the proxy port no configured on the proxy server.

To unset the Git proxy run the below commands in the Git bash. git config --global --unset http.proxy git config --global --unset https.proxy

Check How to configure Git proxy and How to unset the Git Proxy for more details

Srinivas Ramakrishna
  • 1,294
  • 13
  • 21