我无法通过 git 签出 code.google.com 和 github 项目,但我可以正常从 IE/Firefox 浏览器访问它们。关于防火墙后面的 git 代理配置有很多讨论,但不幸的是,这些讨论都不适合我的问题。
以下是我尝试访问 code.google.com 时出现的消息
Cloning into 'smart-adaptive-makefile'...
* Couldn't find host code.google.com in the .netrc file; using defaults
* About to connect() to proxy proxyconf port 1080 (#0)
* Trying 147.243.224.17...
* 0x80077208 is at send pipe head!
* STATE: CONNECT => WAITCONNECT handle 0x8007fba0; (connection #0)
* Connection timed out after 300015 milliseconds
* STATE: WAITCONNECT => COMPLETED handle 0x8007fba0; (connection #-5000)
* STATE: COMPLETED => MSGSENT handle 0x8007fba0; (connection #-5000)
* Closing connection #0
* Couldn't find host code.google.com in the .netrc file; using defaults
* About to connect() to proxy proxyconf port 1080 (#0)
* Trying 147.243.224.17...
* 0x80077208 is at send pipe head!
* STATE: CONNECT => WAITCONNECT handle 0x8007fad8; (connection #0)
* Connection timed out after 300032 milliseconds
* STATE: WAITCONNECT => COMPLETED handle 0x8007fad8; (connection #-5000)
* STATE: COMPLETED => MSGSENT handle 0x8007fad8; (connection #-5000)
* Closing connection #0
error: Connection timed out after 300032 milliseconds while accessing https://[email protected]/p/smart-adaptive-makefile/info/refs
fatal: HTTP request failed
另外,我的 IE/Firefox 使用自动配置脚本,而不是手动配置代理服务器。 在这种情况下,我应该如何配置 git?
BR,若尘
答案1
只要我的代理设置正确,我就能毫无问题地访问防火墙后面的任何外部存储库:
HTTPS_PROXY=http://username:[email protected]:port
HTTP_PROXY=http://username:[email protected]:port
请注意,两个地址都是相同的代理地址(在我的情况下是 http,而不是 https 地址),以及该代理的用户名和密码(不是 GitHub 的)
~/.netrc
(或者%HOME%/_netrc
在 Windows 上,如果您明确定义了%HOME%
环境变量)仅用于外部 repo 身份验证:
machine github.com
login user
password passwd
看 ”Git-如何.netrc
在Windows上使用文件保存用户和密码” 了解更多。