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 @   郭小睿  阅读(184)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· AI 智能体引爆开源社区「GitHub 热点速览」
· 写一个简单的SQL生成工具
点击右上角即可分享
微信分享提示

目录导航