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..proxy

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

       remote..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/8xy

     

    # 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 [email protected] nc %h %p



你可能感兴趣的:(git,杂谈)