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, 有点强迫症

相关推荐
abcnull1 小时前
github开源协议选择
git·github·开源协议
安庆平.Я4 小时前
git互联GitHub 使用教程
git·github
自来也_10 小时前
Git配置代理
git
Jooolin1 天前
【编程史】Git是如何诞生的?这可并非计划之中...
linux·git·ai编程
Lw老王要学习1 天前
VScode 使用 git 提交数据到指定库的完整指南
windows·git·vscode
去旅行、在路上1 天前
Git & Svn
git·svn
abcnull1 天前
github中main与master,master无法合并到main
git·github
养意2 天前
git提交代码和解决冲突修复bug
git·bug
码农黛兮_462 天前
Git 常用命令大全
git
一弓虽2 天前
git 学习
git·学习