標簽:blog class code com img size http tar ext 404 style
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,加入以下行
ProxyCommand /home/lisp/local/bin/connect -H proxy-server:3128 %h %p
ProxyCommand /home/lisp/local/bin/connect -H proxy-server:3128 %h %p Host github.com User loveaborn@foxmail.com Port 443 Hostname ssh.github.com
以上步驟完成後,就行了,如下截圖:
git clone git@github.com:aborn/ulitcs.git
git push
注意:
1. 上面的proxy-server根据你的代理,设置为替换为你的代理服务器的ip地址或者域名
2. 上面的connect.c 文件、编译好的connect文件和git-proxy文件,也可以从这里下载connect.tar.gz 和 git-proxy
3. 我的操作系统为Ubuntu 14.04LTS
Ubuntu Linux下通过代理(proxy)使用git上github.com,码迷,mamicode.com
Ubuntu Linux下通过代理(proxy)使用git上github.com
標簽:blog class code com img size http tar ext 404 style
原文地址:http://blog.csdn.net/loveaborn/article/details/24575659