31

I am using msysgit from behind a proxy. As I said in question Getting git to work with a proxy server

I have set system variable http_proxy to a value. Later I call

git config --global http.proxy $http_proxy

However, if I call something like:

git clone git://git.savannah.gnu.org/gnuprologjava.git

It gives the following error:

git.savannah.gnu.org[0; 140.186.70.72]: errno=No error
fatal: unable to connect a socket (No error)
Community
  • 1
  • 1
  • this works only in my corporate proxy environment which access external IP with port 22 is blocked: http://alpengeist-de.blogspot.com.au/2012/03/github-with-cygwin-git-behind-corporate.html – BMW Feb 16 '17 at 01:05
  • That's not a dupe. That question use `http(s)` url to clone while this one use `git://`. – tsh Jul 05 '22 at 07:28

3 Answers3

23

If you're behind an http proxy, you should be using http git urls. The UsingGit page on Savannah.gnu.org tells you the correct syntax for this. For that repo:

git clone http://git.savannah.gnu.org/r/gnuprologjava.git
Mat
  • 202,337
  • 40
  • 393
  • 406
7

When you are on linux, see this page.

On windows I have solved it this way;

Install Cygwin, and select the socat package. Create a script gitproxy.cmd and save it in the path (I used C:\msysgit\cmd\gitproxy.cmd):

@echo off
C:\cygwin\bin\socat.exe - PROXY:192.168.100.1:\%1:\%2,proxyport=3128

(replace 192.168.100.1 and 3128 with your own proxy ip/port)

Execute the following line to configure the proxy:

git config --global core.gitproxy gitproxy.cmd

Note that the proxy server must accept the CONNECT command for the git port (9418). I have added the following lines to the squid configuration to make this work:

acl SSL_ports port 9418         # git
acl Safe_ports port 9418        # git

(ie configure port 9418 the same way as port 443 in the proxy server)

wimh
  • 15,072
  • 6
  • 47
  • 98
  • FYI, if you're cloning from a git server that has an http git address, I was able to use cygwin's git by simply setting the `http_proxy` shell variable to my proxy server and then doing `git clone http://github.com/blah/blah.git`. You can test that `http_proxy` is working through your proxy by also installing `wget` through cygwin's setup.exe and doing `wget www.google.com`. If `http_proxy` is set correctly, that command will download a file. – Ross Rogers May 16 '13 at 18:17
4

As this was answered by many but this is just for a Windows USER who is behind a proxy with auth.

Re-Installing (first failed, don't remove).

Go to: 
1. msysgit\installer-tmp\etc\gitconfig
    Under [http]
        proxy = http://user:pass@url:port
2. msysgit\installer-tmp\setup-msysgit.sh
      export HTTP_PROXY="http://USER:PASS@proxy.abc.com:8080"

if you have any special char in user/pass use url_encode

Option 2: Set environment variable

HTTP_PROXY=http://proxy.com:8080

Jir
  • 2,985
  • 8
  • 44
  • 66
Ravi Parekh
  • 5,253
  • 9
  • 46
  • 58