- HTTP 形式:
git clone https://github.com/owner/git.git
- SSH 形式:
git clone git@github.com:owner/git.git
如果要设置全局代理,可以依照这样设置:
git config --global http.proxy "http://127.0.0.1:8080"
git config --global https.proxy "http://127.0.0.1:8080"
不推荐直接用全局代理,因为如果挂了全局代理,这样如果需要克隆coding之类的国内仓库,会奇慢无比, 所以我建议使用这条命令,只对github进行代理,对国内的仓库不影响(摘自知乎 汪小九)
git config --global http.https://github.com.proxy "https://127.0.0.1:1080"
git config --global https.https://github.com.proxy "https://127.0.0.1:1080"
git config --global http.proxy "socks5://127.0.0.1:1080"
git config --global https.proxy "socks5://127.0.0.1:1080"
同上
git config --global http.https://github.com.proxy "socks5://127.0.0.1:1080"
git config --global https.https://github.com.proxy "socks5://127.0.0.1:1080"
git config --global --unset http.proxy
git config --global --unset https.proxy
修改 ~/.ssh/config
文件(不存在则新建):
# 必须是 github.com
Host github.com
HostName github.com
User git
# 走 HTTP 代理
# ProxyCommand socat - PROXY:127.0.0.1:%h:%p,proxyport=8080
# 走 socks5 代理(如 Shadowsocks)
# ProxyCommand nc -v -x 127.0.0.1:1080 %h %p