Created
January 18, 2017 08:25
-
-
Save bluethon/45766d0a4541ab633e32a49b6c4e4bdd to your computer and use it in GitHub Desktop.
设置git使用socks5代理
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git config --global http.proxy 'socks5://127.0.0.1:1080' | |
git config --global https.proxy 'socks5://127.0.0.1:1080' |
如果只想对 GitHub 进行代理,则可以这么做:
# 以代理端口 7890 为例
git config --global http.https://git.521000.best.proxy socks5h://127.0.0.1:7890
# 取消代理
git config --global --unset http.https://git.521000.best.proxy
我实际的经验是,如果git远程仓库是通过ssh连接的,换成https连接才可以走代理。因为ssh不走代理,那么他解析不了dns的情况下就报错了。
我实际的经验是,如果git远程仓库是通过ssh连接的,换成https连接才可以走代理。因为ssh不走代理,那么他解析不了dns的情况下就报错了。
为 ssh 配置代理就好了
# cat .ssh/config
Host xxxx
# socks5 proxy
# ProxyCommand nc -X 5 -x 127.0.0.1:1080 %h %p
# http proxy
# ProxyCommand nc -X connect -x 127.0.0.1:1081 %h %p
我实际的经验是,如果git远程仓库是通过ssh连接的,换成https连接才可以走代理。因为ssh不走代理,那么他解析不了dns的情况下就报错了。
为 ssh 配置代理就好了
# cat .ssh/config Host xxxx # socks5 proxy # ProxyCommand nc -X 5 -x 127.0.0.1:1080 %h %p # http proxy # ProxyCommand nc -X connect -x 127.0.0.1:1081 %h %p
Works for me! thx
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
这都啥啊 没反应