Git:在 git 中克隆远程存储库时无法解决主机 github.com 错误 [英] Git: Could not resolve host github.com error while cloning remote repository in git
问题描述
我做了什么:我在 Github 上创建了一个远程存储库,我正在尝试在我的本地机器上克隆远程存储库.在克隆时,我提供了克隆 URL &目标文件夹.
What I did: I have created a remote repository on Github and I am trying to clone the remote repository on my local machine. While cloning I am providing the clone URL & target folder.
但是每次我尝试克隆时,都会收到此错误:
But every time I try to clone, I am getting this error:
错误:致命:无法访问'https://github.com/hyperion057/spring-repo.git/': 无法解析主机:github.com"
Error: "fatal: unable to access 'https://github.com/hyperion057/spring-repo.git/': Could not resolve host: github.com"
我需要做什么才能连接到 GitHub?
What do I need to do to connect to GitHub ?
推荐答案
我需要配置代理设置吗?因为我的办公室有代理服务器.
do i need to configure proxy settings? because my office has got proxy servers.
是的,您可以通过设置 HTTP_PROXY
和 HTTPS_PROXY
环境变量来实现.
Yes, you can do so by setting HTTP_PROXY
, and HTTPS_PROXY
environment variables.
参见与 github 同步":
set HTTPS_PROXY=http://<login_internet>:<password_internet>@aproxy:aport
set HTTP_PROXY=http://<login_internet>:<password_internet>@aproxy:aport
set NO_PROXY=localhost,my.company
(为了避免将您的凭据 -- 用户名/密码 -- 在代理 URL 中清除,请参见下文)
(To avoid putting your credentials -- username/password -- in clear in the proxy URL, see below)
注意NO_PROXY
,以允许访问您公司的内部网站
Note the NO_PROXY
, to allow to access internal site to your company
你也可以在你的 git 配置中注册:
You also can register that in your git config:
git config --global http.proxy http://<login_internet>:<password_internet>@aproxy:aport
但是如果您的代理 Git 设置不正确,请将其删除:
But if you have incorrect proxy Git settings, remove them:
cd /path/to/repo
git config --unset http.proxy
git config --global --unset http.proxy
git config --system --unset http.proxy
git config --unset https.proxy
git config --global --unset https.proxy
git config --system --unset https.proxy
# double-check with:
git config -l --show-origin | grep -i proxy
无需凭据:使用 genotrance/px
.
如果您和我一样在一家拥有 NTLM 代理的公司,您需要做的就是:
No credentials needed: use genotrance/px
.
If you are, as I am, in a company behind a NTLM proxy, all you need to do is:
- 解压
px-v0.4.0.zip
任何你想要的 - 更改
px.ini
配置文件(将其放入%USERPROFILE%
),更改server
行:
- unzip
px-v0.4.0.zip
anywhere you want - change the
px.ini
config file (put it in%USERPROFILE%
), chaging theserver
line:
[proxy]
server = proxy.my.company:8080 <= use your company proxy:port
listen = 127.0.0.1
port = 3128
px
代理将重用当前 Widows 会话中的那些,或者通过 Microsoft SSPI 或 Microsoft Kerberos)
px
proxy will reuse the ones from the current Widows session, either through Microsoft SSPI or Microsoft Kerberos)这会给你:
set HTTPS_PROXY=http://127.0.0.1:3128
set HTTP_PROXY=http://127.0.0.1:3128
set NO_PROXY=localhost,my.company
这篇关于Git:在 git 中克隆远程存储库时无法解决主机 github.com 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!