如果從 remote repository clone 或 fetch 時遇到問題,或者遇到諸如以下錯誤,例如
unable to access '...' Couldn't resolve host '...'
則可能需要設置 proxy
例如:
git config --global http.proxy http://proxyUsername:[email protected]:port
又或者特殊的 domain,例如:
git config --global http.https://domain.com.proxy http://proxyUsername:[email protected]:port
git config --global http.https://domain.com.sslVerify false
設定 http.<url>.sslVerify to false 能幫助你快速實現,假如你的 workplace
使用 man-in-the-middle HTTPS proxying。
Longer term, you could get the
root CA that they are applying to the certificate chain
and specify it with either http.sslCAInfo or http.sslCAPath.
另請參見git-config documentation ,尤其是以下內容 部分(有關HTTPS / SSL問題)。
http.sslVerifyhttp.sslCAInfohttp.sslCAPathhttp.sslCerthttp.sslKeyhttp.sslCertPasswordProtected
您可以使用 --global 配置在 ~/.gitconfig 的file, 或者 local 在 .git/config file.
如果對所有 repos 的所有 access 都需要此proxy,請設置 global proxy
git config --global http.proxy http://proxyUsername:[email protected]:port
If you wish to specify that a proxy should be used for just
some URLs that specify the URL as a git config subsection
using http.<url>.key notation:
git config --global http.https://domain.com.proxy http://proxyUsername:[email protected]:port
Which will result in the following in the ~/.gitconfig file:
[http]
[http "https://domain.com"]
proxy = http://proxyUsername:[email protected]:port
If you're still having trouble cloning or fetching and are now getting
an unable to access 'https://...': Unknown SSL protocol error in connection to ...:443 then
you may decide to switch off SSL verification for the single operation
by using the -c http.sslVerify=false option
git -c http.sslVerify=false clone https://domain.com/path/to/git
Once cloned, you may decide set this for just this cloned
repository's .git/config by doing. Notice the absence of the --global
git config http.sslVerify false
If you choose to make it global then limit it to a URL using
the http.<url>.sslVerify notation:
git config --global http.https://domain.com.sslVerify false
Which will result in the following in the ~/.gitconfig file:
[http]
[http "https://domain.com"]
proxy = http://proxyUsername:[email protected]:port
sslVerify = false
To show the current configuration of all http sections
git config --global --get-regexp http.*
If you are in a locally cloned repository folder then you drop
the --global and see all current config:
git config --get-regexp http.*
Use the --unset flag to remove configuration being specific about the
property -- for example whether it was http.proxy or http.<url>.proxy.
Consider using any of the following:
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