Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use git behind a proxy [duplicate]

Tags:

git

proxy

People also ask

How do I git behind a proxy?

Setting the proxy for Git Run the following commands replacing USERNAME , PASSWORD , PROXY_ADDRESS , and PROXY_PORT with your network's information: git config --global --add http. proxy http://USERNAME:PASSWORD@PROXY_ADDRESS:PROXY_PORT. git config --global --add https.


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

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)


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:[email protected]:8080"

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

Option 2: Set environment variable

HTTP_PROXY=http://proxy.com:8080