HTTP 代理
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
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 代理
首先配置好 http 协议代理服务器然后需要 socat zuo http 到 git 协议的转换
netcat-openbsd
or socat to connect through as follows…
-
Install `socat`. For example, on Debian/Ubuntu, just `sudo apt-get install socat`.
-
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.)
-
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 代理
Host git.host.com
User gitolite
Hostname 192.168.1.1
ProxyCommand ssh git@git.proxy.com nc %h %p