How do I pull from a Git repository through an HTTP proxy?
You can also set the HTTP proxy that Git uses in global configuration property http.proxy
:
git config --global http.proxy http://proxy.mycompany:80
To authenticate with the proxy:
git config --global http.proxy http://mydomain\\myusername:mypassword@myproxyserver:8080/
(Credit goes to @EugeneKulabuhov and @JaimeReynoso for the authentication format.)
There's some great answers on this already. However, I thought I would chip in as some proxy servers require you to authenticate with a user Id and password. Sometimes this can be on a domain.
So, for example if your proxy server configuration is as follows:
Server: myproxyserver
Port: 8080
Username: mydomain\myusername
Password: mypassword
Then, add to your .gitconfig
file using the following command:
git config --global http.proxy http://mydomain\\myusername:mypassword@myproxyserver:8080
Don't worry about https
. As long as the specified proxy server supports http, and https, then one entry in the config file will suffice.
You can then verify that the command added the entry to your .gitconfig
file successfully by doing cat .gitconfig
:
At the end of the file you will see an entry as follows:
[http]
proxy = http://mydomain\\myusername:mypassword@myproxyserver:8080
That's it!
What finally worked was setting the http_proxy
environment variable. I had set HTTP_PROXY
correctly, but git apparently likes the lower-case version better.
If you just want to use proxy on a specified repository, don't need on other repositories. The preferable way is the -c, --config <key=value>
option when you git clone
a repository. e.g.
$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git --config "http.proxy=proxyHost:proxyPort"
It looks like you're using a mingw compile of Git on windows (or possibly another one I haven't heard about). There are ways to debug this: I believe all of the http proxy work for git is done by curl. Set this environment variable before running git:
GIT_CURL_VERBOSE=1
This should at least give you an idea of what is going on behind the scenes.