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
Git Push Error - Could not resolve host name
提问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 origin
for your upstream repo.
并仔细检查与origin
您的上游 repo关联的 url 。
Once you have the right url, update your remote origin with another git remote
command:
获得正确的 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 存储库名称,这也是一个很好的做法。