让你的Git能够顺利克隆仓库

1 篇文章 0 订阅
1 篇文章 0 订阅

简言(省流)

已知HTTP端口,快速配置

git config --global http.proxy 'http://127.0.0.1:1080' 
git config --global https.proxy 'https://127.0.0.1:1080'
unable to access '...' Couldn't resolve host '...' 如果你在克隆或从远程存储库获取时遇到类似问题,或者收到类似错误,那就可能需要配置额外配置。

可以尝试:

git config --global http.proxy http://proxyUsername:proxyPassword@proxy.server.com:port
 
  

或者对于特定的域,例如:

git config --global http.https://domain.com.proxy http://proxyUsername:proxyPassword@proxy.server.com:port
git config --global http.https://domain.com.sslVerify false

如果你的工作场所采用中间人 HTTPS ,则设置http.<url>.sslVerify。你可以获取他们应用于证书链的根 CA,并使用或指定它。falsehttp.sslCAInfohttp.sslCAPath

如果你遇到 HTTPS/SSL 问题,另请参阅git-config文档,尤其是以下部分

  • http.sslVerify
    http.sslCAInfo
    http.sslCAPath
    http.sslCert
    http.sslKey
    http.sslCertPasswordProtected

详细

配置GitConfig

您可以使用开关在用户 ~/.gitconfig 文件中全局配置这些内容 --global,或者在其文件中对存储库进行本地配置 .git/config

设置GlobalProxy

如果所有存储库的访问都需要此代理,则配置全局代理

git config --global http.proxy http://proxyUsername:proxyPassword@proxy.server.com:port
指定URL

如果您希望指定仅对某些 URL 使用代理,则可以使用http.<url>.key以下表示法将 URL 指定为 git config 子部分:

git config --global http.https://domain.com.proxy http://proxyUsername:proxyPassword@proxy.server.com:port

这将导致文件中出现以下内容~/.gitconfig

[http]
[http "https://domain.com"]
	proxy = http://proxyUsername:proxyPassword@proxy.server.com:port
处理后续 SSL 协议错误

如果你仍然无法克隆或获取,并且现在得到了,unable to access 'https://...': Unknown SSL protocol error in connection to ...:443那么你可以决定使用选项关闭单个操作的 SSL-c http.sslVerify=false验证

git -c http.sslVerify=false clone https://domain.com/path/to/git

克隆完成后,您可以决定只为这个克隆的存储库设置此项.git/config。请注意--global

git config http.sslVerify false

如果您选择将其设为全局,则使用以下符号将其限制为 URL http.<url>.sslVerify

git config --global http.https://domain.com.sslVerify false

这将导致文件中出现以下内容~/.gitconfig

[http]
[http "https://domain.com"]
	proxy = http://proxyUsername:proxyPassword@proxy.server.com:port
	sslVerify = false

显示当前配置

显示所有http部分的当前配置

git config --global --get-regexp http.*

如果您位于本地克隆的存储库文件夹中,则可以删除 --global 并查看所有当前配置:

git config --get-regexp http.*

取消全局设置或 SSL 验证

使用--unset标志删除特定于属性的配置。考虑使用以下任何一种:

git config --global --unset http.proxy
git config --global --unset http.https://domain.com.proxy

git config --global --unset http.sslVerify
git config --global --unset http.https://domain.com.sslVerify

  • 5
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值