1

I want to use git at work through a proxy on Windows 7. My company has various proxies available. To get past the proxy for Python pip usage, I used the Cntlm program. With Cntlm, I was able to specify my domain\username and password, and used that to connect through / bypass the proxy server.

Not I want to use git. I don't know where to put the domain name in the proxy setting of git. Here are the steps that I followed in cmd on Windows 7.

set HTTP_PROXY=http://domain\username:password@proxyaddress:proxyport
git config --global http.proxy $HTTP_PROXY
git clone git://github.com/destination.git folder

This keeps timing out eventhough all my information is correct and Cntlm works with the same information. Can someone please assist in the correct procedure to get git to work through a proxy such as this?

nwinkler
  • 52,665
  • 21
  • 154
  • 168
Cornel Verster
  • 1,664
  • 3
  • 27
  • 55

2 Answers2

3

To benefit from the https proxy settings, you should at least use the https protocol.

# not:
git clone git://github.com/destination.git folder
# but
git clone https://github.com/destination.git folder

Note: if the environment variable is set, it will be picked up by git, even if the git config http(s).proxy isn't done.
And you should have both HTTP_PROXY and HTTP_PROXY defined.

you will find a more complete example at "Setting git to work behind NTLM-authenticated proxy: cntlm to the rescue ".
The OP Cornel Verster mentions in the comments:

When using Cntlm, you should set your git http.proxy to localhost:3128 as well as you HTTP_PROXY (127.0.0.1:3128) and HTTPS_PROXY (127.0.0.1:3128) variables.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks, that helped me to understand a bit more! I still get the error: fatal: unable to access 'https://github.com/scottmuc/yari.git/': Unknown SSL protocol error in connection to github.com:443? – Cornel Verster Sep 01 '15 at 07:05
  • @CornelVerster Did you set the HTTPS_PROXY environment variable? – VonC Sep 01 '15 at 07:06
  • No, I only used git config --global http.proxy [proxy adress]. Should I set the HTTPS_PROXY environmental variable? – Cornel Verster Sep 01 '15 at 07:09
  • @CornelVerster forget about git config for a moment. set `HTTPS_PROXY=http://domain\username:password@proxyaddress:proxyport` (note that I use the same http url for the HTTPS proxy env variable). Here is an example: http://stackoverflow.com/a/20371843/6309 – VonC Sep 01 '15 at 07:10
  • Ok, I set the HTTPS_PROXY environmental variable, but unfortunately still get the same error when executing git clone https://github.com/destination.git folder – Cornel Verster Sep 01 '15 at 07:12
  • @CornelVerster What git version are you using? – VonC Sep 01 '15 at 07:13
  • @CornelVerster just to be sure, `destination.git` is actually something like `ausername/areponame.git`, right? – VonC Sep 01 '15 at 07:14
  • git version 2.4.5. And yes, destination.git is a valid git destination. – Cornel Verster Sep 01 '15 at 07:15
  • Actually, you can clone a github repo using an http url, so you can stick to HTTP_PROXY. See also https://sparethought.wordpress.com/2012/12/06/setting-git-to-work-behind-ntlm-authenticated-proxy-cntlm-to-the-rescue/, to check if that help. – VonC Sep 01 '15 at 07:19
  • Awesome! That wordpress article gave me the correct solution! When using Cntlm, you should set your git http.proxy to localhost:3128 as well as you HTTP_PROXY (http://127.0.0.1:3128) and HTTPS_PROXY (https://127.0.0.1:3128) variables. Thanks for the help! – Cornel Verster Sep 01 '15 at 07:55
  • @CornelVerster Great! I have edited the answer to reflect your conclusion, for more visibility. – VonC Sep 01 '15 at 07:59
0

On windows you must use %YOUR_VAR% to reference your variable. So i think the main problem is this error. You have already a post about that here -> How do I pull from a Git repository through an HTTP proxy?

Community
  • 1
  • 1
Etienne Prothon
  • 982
  • 10
  • 30