git如何設置使用代理


使用命令直接設定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如何設置使用代理


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM