日期:2014-05-16 浏览次数:20941 次
github.com,作为程序员的代码仓库,我们经常会用到。但有时候我们不能直接通过网络链接它,只能通过代理。
这里我有一台代理服务器,起初我以为在终端设置了代理环境就行了,其设置为在你的~/.bashrc里增加以下几行:
export http_proxy="http://proxy-server:3128/" export https_proxy="http://proxy-server:3128/" export ftp_proxy="http://proxy-server:3128/"
source ~/.bashrc
但使用git clone就不行
git clone git@github.com:aborn/ulitcs.git通过这两篇文章知道了原因:在windows上通过代理访问github.com 和 Using git over proxy
配制过程分为以下几步:
1. 安装socat,在ubuntu下使用以下命令安装
sudo apt-get install socat
#!/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 git-proxy # git config --global core.gitproxy git-proxy # # # Configuration. Common proxy ports are 3128, 8123, 8000. _proxy=proxy-server _proxyport=3128 exec socat STDIO PROXY:$_proxy:$1:$2,proxyport=$_proxyport
cp git-proxy /home/lisp/local/bin/将该目录加入到PATH,加入以下内容到~/.bashrc,然后souce ~/.bashrc
export PATH=$PATH:/home/lisp/local/bin
source ~/.bashrc
gitproxy = git-proxy我.gitconfig文件内容如下:
[push] default = simple [user] name = aborn email = loveaborn@foxmail.com [core] editor = emacs gitproxy = git-proxy [https] proxy = http://proxy-server:3128 [http] proxy = http://proxy-server:3128
5. 下载转换协议文件connect.c,下载地址点击
只要下载connect.c文件即可,然后编译
gcc -o connect connect.c
6. 修改~/.ssh/config,加入以下行