简言(省流)
已知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,并使用或指定它。false
http.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