git的代理配置

来自: http://segmentfault.com/q/1010000000118837

Git 目前支持的三种协议 http://git:// 和 ssh:// 其代理配置各不相同。http.proxy 用于 http://协议,core.gitproxy 用于 git:// 协议,ssh:// 协议的代理需要配置 ssh 的 ProxyCommand 参数。

对于所有的协议全部使用 SSH 隧道进行代理

HTTP 协议的配置

[http]         #这里是因为 Git 使用 libcurl 提供 http 支持         proxy = socks5://127.0.0.1:7070 

GIT 协议的配置

建立 /path/to/socks5proxywrapper 文件,使用 https://bitbucket.org/gotoh/connect 工具进行代理的转换,各发行版一般打包为 proxy-connect 或者 connect-proxy。

#!/bin/sh connect -S 127.0.0.1:7070 "$@" 

配置 git

[core]         gitproxy = /path/to/socks5proxywrapper 

或者

export GIT_PROXY_COMMAND="/path/to/socks5proxywrapper" 

SSH 协议的配置

建立 /path/to/soks5proxyssh 文件

#!/bin/sh ssh -o ProxyCommand="/path/to/socks5proxywrapper %h %p" "$@" 

配置 git 使用该 wrapper

export GIT_SSH="/path/to/socks5proxyssh“ 

当然也可以直接配置 ~/.ssh/config 的 ProxyCommand


所有协议全部使用 http 代理

HTTP 协议配置

[http]     proxy = http://192.168.1.100:8080 

/path/to/socks5proxywrapper 文件改为

#!/bin/sh connect -H 192.168.1.100:8080 "$@" 

针对域名启用代理

gitproxy 参数提供 * for * 结构,具体看 man git-config 的 core.gitproxy 部分。

posted @ 2013-05-25 22:02  super119  阅读(1169)  评论(0编辑  收藏  举报