Git代理

 

git clone git://github.com/SpringSource/spring-framework.git

Cloning into 'spring-framework'...

fatal: unable to connect to github.com:

github.com[0: 207.97.227.239]: errno=Connection timed out

 

因为防火墙阻止了git协议,需要为git请求配置代理服务器。

Git behind a proxy

git knows about http_proxy environment variable, but tunneling the git procotoll is sliently more complicated:

 

1. 安装socat

sudo apt-get install socat

 

2. 创建socat脚本

create a script git-proxy.sh containing (replace your_proxy and your_proxyport):

nano git-proxy.sh

#!/bin/bash

socat STDIO PROXY:10.11.70.71:$1:$2,proxyport=80

 

sudo chmod +x git-proxy.sh

 

3. 配置git代理

tell git to use git-proxy.sh as proxy command

export GIT_PROXY_COMMAND=/home/hanl/codes/git-proxy.sh

 

or:

nano .profile

export GIT_PROXY_COMMAND=/home/hanl/codes/git-proxy.sh

source .profile

 

git clone git://github.com/SpringSource/spring-framework.git

Cloning into 'spring-framework'...

remote: Counting objects: 122624, done.

remote: Compressing objects: 100% (39039/39039), done.

你可能感兴趣的:(git)