git设置代理

背景

国内提交代码到github,因为网络原因很蛋疼~需要设置代理,才能正常且快速的提交代码。

刚巧我有国外的云服务器,自己搭建了一个socket5代理。

设置代理

命令设置代理

git config --global https.proxy "socks5://ip:1080"

# socks
git config --global http.proxy 'socks5://127.0.0.1:1080' 
git config --global https.proxy 'socks5://127.0.0.1:1080'
# http
git config --global http.proxy http://127.0.0.1:1080 
git config --global https.proxy https://127.0.0.1:1080

# 只对github.com使用代理,其他仓库不走代理
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

# 取消github代理
git config --global --unset http.https://github.com.proxy
git config --global --unset https.https://github.com.proxy

--global 表示全局,不需要可以不加,不建议设置全局代理, 多环境下可能混乱。

修改配置设置代理

直接修改 ~/.gitconfig 文件

取消代理

git config --global --unset http.proxy
git config --global --unset https.proxy
posted @ 2023-04-09 14:44  郭小睿  阅读(172)  评论(0编辑  收藏  举报