ubuntu git http proxy配置

2170阅读 0评论2015-04-19 电子学习员
分类:LINUX

    有些公司上网会有统一的http proxy服务器,一般公司会给你http的代理配置,这样你就可以通过http协议上网了,如果git server提供了http访问的方式,是没有问题的,但是如果git server只提供ssh访问,此时,就不能进行git 操作了,需要做一些配置才行。

1. 安装socat
   sudo apt-get install socat
2. 编写配置文件gitproxy
  (1)找到socat的安装目录,通常才/usr/bin,并在此目录下创建gitproxy文件,文件内容如下:

点击(此处)折叠或打开

  1. #!/bin/sh
  2. # Use socat to proxy git through an HTTP CONNECT firewall.
  3. # Useful if you are trying to clone git:// from inside a company.
  4. # Requires that the proxy allows CONNECT to port 9418.
  5. #
  6. # Save this file as gitproxy somewhere in your path (e.g., ~/bin) and then run
  7. # chmod +x gitproxy
  8. # git config --global core.gitproxy gitproxy
  9. #
  10. # More details at http://tinyurl.com/8xvpny
  11.  
  12. # Configuration. Common proxy ports are 3128, 8123, 8000.
  13. _proxy=proxy.yourcompany.com  #贵公司的代理服务器地址
  14. _proxyport=3128               #端口 
  15.  
  16. exec socat STDIO PROXY:$_proxy:$1:$2,proxyport=$_proxyport
(2)增加gitproxy可执行权限
     sudo chmod a+x gitproxy
(3)配置git的全局代理
      git config --global core.gitporxy gitproxy

经过以上步骤,就可以执行git clone操作了。




上一篇:MMC 卡驱动分析
下一篇:关于Android中的文件读写