git 使用代理大全

HTTP 代理

直接配置  http_proxy 环境变量
git config http.proxy

       http.proxy
           Override the HTTP proxy, normally configured using the http_proxy, https_proxy, and
           all_proxy environment variables (see curl(1)). This can be overridden on a per-remote
           basis; see remote.<name>.proxy

为固定的 remote 配置单独的 https 代理

       remote.<name>.proxy
           For remotes that require curl (http, https and ftp), the URL to the proxy to use for that
           remote. Set to the empty string to disable proxying for that remote.

使用方法:
git config http.proxy 192.168.2.1

GIT 代理

git 协议的 端口号 是9418, 开通这个端口代理的服务器不多,这里直接上用 https 的代理转换成 git 代理

首先配置好 http 协议代理服务器然后需要 socat zuo http 到 git 协议的转换

netcat-openbsd or socat to connect through as follows…

  1. Install `socat`.  For example, on Debian/Ubuntu, just `sudo apt-get install socat`.

  2. Create a script called `gitproxy` in your bin directory;

    1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  

    #!/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

           

    view raw         gitproxy-socat          This Gist brought to you by GitHub.

    You will need to replace proxy.yourcompany.com with the name of your proxy host and the port with the port used by the proxy (common ports include 3128, 8123 and 8000). (If the javascript is broken, visit [Gist 49288][gist] and download the raw file; or use the original commands as reproduced in the comments.)

  3. Configure `git` to use it:

    $ git config --global core.gitproxy gitproxy

That’s it!  Your git clone commands should now transparently accept git:// URLs.


SSH 代理

首先要保证 代理服务器能够有 ssh 连接目的服务器的权限
配置 ssh  vi /home/jxdong/.ssh/config

Host git.host.com
User gitolite
Hostname 192.168.1.1
ProxyCommand ssh git@git.proxy.com nc %h %p



转载于:https://my.oschina.net/jingxia/blog/697543

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值