使用命令直接設定socks或者http代理即可。
socks代理:
git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'
也可以直接修改~/.gitconfig文件。
vi ~/.gitconfig
新建或修改這兩項配置
[http]
proxy = socks5://127.0.0.1:1080
[https]
proxy = socks5://127.0.0.1:1080
http/https代理
git config --global https.proxy http://127.0.0.1:8080
git config --global https.proxy https://127.0.0.1:8080
然后再git clone等命令就會自動走代理了。
如果要取消代理:
git config --global --unset http.proxy
git config --global --unset https.proxy
這里要說明一下,帶參數是臨時的,修改配置文件是永久變更,修改后最好重啟所有 git bash 保證設置生效。
參考資料:
git如何設置使用代理
