http://www.vpsee.com/2011/07/how-to-use-git-through-a-http-proxy/
主要参考了这个帖子。
1. 如果是http或者https协议的,那比较简单
export http_proxy="http://proxy_ip_address:port"
export https_proxy="http://proxy_ip_address:port"
2. 如果是git协议的, 那需要安装socat。
编辑如下脚本,
#!/bin/bash
PROXY=9.186.9.18
PROXYPORT=3128
PROXYAUTH=username:passwd
exec socat STDIO PROXY:$PROXY:$1:$2,proxyport=$PROXYPORT,proxyauth=$PROXYAUTH
在.gitconfig中加如
[core]
gitproxy = gitproxy
开始还是不行,后来发现是因为squid中不允许git端口 9418通过。
在/etc/squid/squid.conf中添加
acl git port 9418
http_access allow git
好啦,可以用了哈