Friday, March 21, 2014

How To Use Git Behind Proxy


If you would like to use git behind proxy, you will have to instruct Git to use proxy . Note that setting http_proxy environment variable alone is not sufficient since the variable is ignored by git.

The below mentioned commands would create a user-specific git configuration file (~/.gitconfig) updated with proxy details:

$ export http_proxy=http://myproxy.com:portnumber
$ git config --global http.proxy $http_proxy

or

$ git config --global http.proxy http://myproxy.com:portnumber

You can ofcourse replace myproxy.com with an IP address too.

In case your proxy needs authentication then you will have to supply the authentication details (i.e. your proxy's username/password) to the GIT's configuration file and this can be done as follows:
$ export http_proxy=http://proxyuser:proxypassword@myproxy.com:portnumber
$ git config --global http.proxy $http_proxy

or

$ git config --global http.proxy http://proxyuser:proxypassword@myproxy.com:portnumber