GIT代理配置和遇到的问题

1. 配置

  • 配置代理
sh 复制代码
# 配置, 如果代理不需要账号密码不用配置[用户名:密码@], 如果密码有特殊字符, 使用url编码后使用, 如果代理支持https, 可以尝试使用https, 我没有用过
git config --global http.sslVerify false
git config --global http.http://gitee.com.proxy http://用户名:密码@yourproxy:port
git config --global --add http.https://gitee.com.proxy http://用户名:密码@yourproxy:port
git config --global http.http://github.com.proxy http://用户名:密码@yourproxy:port
git config --global --add http.https://github.com.proxy http://用户名:密码@yourproxy:port
  • 配置后结果文件位于: ~/.gitconfig
sh 复制代码
# 配置后配置文件如下
[http]
	sslVerify = false
[http "http://gitee.com"]
	proxy = http://用户名:密码@yourproxy:port
[http "https://gitee.com"]
	proxy = http://用户名:密码@yourproxy:port
[http "http://github.com"]
	proxy = http://用户名:密码@yourproxy:port
[http "https://github.com"]
	proxy = http://用户名:密码@yourproxy:port
  • 移除配置
sh 复制代码
# 移除配置
git config  --global --unset http.proxy
git config  --global --unset http.sslVerify
git config  --global --unset http.http://gitee.com.proxy
git config  --global --unset http.https://gitee.com.proxy
git config  --global --unset http.http://github.com.proxy
git config  --global --unset http.https://github.com.proxy

遇到的问题

因为一直以为有一个叫做https配置, 所以总是去配置https "https://gitee.com", 导致总是配置不成功, 可以通过如下配置去证明

sh 复制代码
# 没有https配置
# 如下配置可以证明, 配置将不会生效
[https "https://github.com"]
	proxy = http://用户名:密码@yourproxy:port
	sslVerify = false

你会发现看似非常合理的配置, 其实没有任何作用, 这个误导很容易导致总是配置不成功

我的现象就是如果配置成全局的就可以, 可以一旦改成指定域名就不能使用了, 就是受到这个不存在的配置项误导, 配置成全局会导致公司内部的代码仓库不能使用http, 只能使用ssh, 有点强迫症

相关推荐
Aurora_th16 小时前
浙江海洋大学 资料共享 期末考试卷、课程资料等
git·github
奶茶树19 小时前
【C++】13. C++11新特性【上】
c语言·开发语言·c++·git·github
夏至春来-美美1 天前
git clone报错
git
拂拉氏1 天前
【Linux】 开发工具(Makefile、git、cgdb)解析与对于操作系统的基础认识
linux·git·操作系统·makefile·cgdb
番茄不是西红柿kk2 天前
deepseek-harness跨平台桌面端二开项目(附git仓库地址+安装包)
git·agent·codex·deepseek·deepseekharness
leoZ2312 天前
10-Git 仓库蒸馏术:从代码仓库到 OpenClaw 虚拟人-蒸馏工具链
大数据·git·深度学习·神经网络·目标检测·elasticsearch·lstm
fpcc2 天前
工具使用—git diff命令分析说明
git·工具
console.log('npc')2 天前
Git 删除指定提交记录操作指南
git
随风丶飘2 天前
[特殊字符] 告别“update“和“fix bug“——Smart Git Commit LLM 让 AI 帮你写专业的 Git 提交信息
人工智能·git·bug
yanlaifan2 天前
git clone时候指定换行符
git