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 config中注册它:
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
代理将通过 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屋!