1. 安装socat
sudo apt-get install socat
2. 编写配置文件gitproxy
(1)找到socat的安装目录,通常才/usr/bin,并在此目录下创建gitproxy文件,文件内容如下:
点击(此处)折叠或打开
-
#!/bin/sh
-
# Use socat to proxy git through an HTTP CONNECT firewall.
-
# Useful if you are trying to clone git:// from inside a company.
-
# Requires that the proxy allows CONNECT to port 9418.
-
#
-
# Save this file as gitproxy somewhere in your path (e.g., ~/bin) and then run
-
# chmod +x gitproxy
-
# git config --global core.gitproxy gitproxy
-
#
-
# More details at http://tinyurl.com/8xvpny
-
-
# Configuration. Common proxy ports are 3128, 8123, 8000.
-
_proxy=proxy.yourcompany.com #贵公司的代理服务器地址
-
_proxyport=3128 #端口
-
- exec socat STDIO PROXY:$_proxy:$1:$2,proxyport=$_proxyport
sudo chmod a+x gitproxy
(3)配置git的全局代理
git config --global core.gitporxy gitproxy
经过以上步骤,就可以执行git clone操作了。