https 访问 github
git config --global http.https://github.com.proxy socks5://127.0.0.1:7890
上面命令运行完成后,在 ~/.gitconfig 文件中会增加以下条目:
[http "https://github.com"]
proxy = socks5://127.0.0.1:7890
取消代理
git config --global --unset http.https://github.com.proxy
ssh 方式访问 github
- mac 设置方式
需要修改 ~/.ssh/config 文件,没有的话新建一个,同样仅为 github.com 设置代理: Host github.com User git ProxyCommand nc -v -x 127.0.0.1:7890 %h %p
- windows 设置方式
# 如果是在 Windows 下, 则需要个性 %home%.ssh\config , 其中内容类似于: Host github.com User git ProxyCommand connect -S 127.0.0.1:7890 %h %p 这里-S表示使用socks5代理, 如果是http代理则为-H. connect工具git自带, 在\mingw64\bin\下面.
以上 7890 需要修改为你本地的 socks5 的端口
参考:https://gist.github.com/laispace/666dd7b27e9116faece6
转载请注明:MitNick » github拉代码慢的解决方案(mac/windows)