Git 推送错误 - 无法解析主机名

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25931684/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 02:30:09  来源:igfitidea点击:

Git Push Error - Could not resolve host name

gitpush

提问by Narendra Kumar Shastri

nshastri@N-SHASTRI ~/datasciencecoursera (master)
$ git push origin master

ssh: Could not resolve hostname https: no address associated with name

fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

ssh:无法解析主机名 https:没有与名称关联的地址

致命:无法从远程存储库读取。

请确保您拥有正确的访问权限并且存储库存在。

回答by VonC

Simply type:

只需键入:

git remote -v

and double-check the url associated with originfor your upstream repo.

并仔细检查与origin您的上游 repo关联的 url 。

Once you have the right url, update your remote origin with another git remotecommand:

获得正确的 url 后,使用另一个git remote命令更新您的远程源:

git remote set-url origin /the/right/url

In your case, the url is wrong:

在您的情况下,网址是错误的:

https:/github.com/nkshastri/datasciencecoursera.git
# instead of:
https://github.com/nkshastri/datasciencecoursera.git
     ^^^^

Simply type:

只需键入:

git remote set-url origin https://[email protected]/nkshastri/datasciencecoursera

Then try again:

然后再试一次:

git push -u origin master

(with master, not maaster)

(有master,没有maaster

回答by vancexu

Sometimes this can be caused by a network issue. Try restarting your wifi or, if the repository is behind a VPN, make sure you are on the VPN.

有时这可能是由网络问题引起的。尝试重新启动您的 wifi,或者,如果存储库在 VPN 后面,请确保您在 VPN 上。

回答by noririco

You are probably trying to connect a FALSE NAME DIR your repository name should be the SAME as your folder name in local environment.

您可能正在尝试连接 FALSE NAME DIR 您的存储库名称应该与本地环境中的文件夹名称相同。

git repo: gitRepo folder name: gitRepo now you can push

git repo: gitRepo 文件夹名称: gitRepo 现在你可以推送了

it is also a good practice to first CLONE your new repository to a different folder and then you can COPY your code to this new folder and then change its name to the right git repository name.

首先将您的新存储库 CLONE 到不同的文件夹,然后您可以将代码复制到这个新文件夹,然后将其名称更改为正确的 git 存储库名称,这也是一个很好的做法。

回答by Arul Mani

For me in ~/.git-credentialsI have two credential is has been stored. So I keep one that I want to interact now push, pull working fine.

对于我来说,~/.git-credentials我有两个凭证已被存储。所以我保留了一个我现在想要交互的推,拉工作正常。

For more information about git-credentials follow this link

有关 git-credentials 的更多信息,请访问此链接