Ruby-on-rails 无法推送到 github,ssh:无法解析主机名
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16548173/
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
Cannot push to github, ssh: Could not resolve hostname
提问by A Ali
I can't get pass this, have remade the repository multiple times, made ssh keys over
我无法通过这个,多次重新制作存储库,制作了 ssh 密钥
--------------
demo_app <username>$ git remote add origin [email protected]:<username>/demo_app.git
fatal: remote origin already exists.
$ git push -u origin master
---
ssh: Could not resolve hostname git: nodename nor servname provided, or not known
---
fatal: Could not read from remote repository.
---
Please make sure you have the correct access rights
---
and the repository exists.
----------
---------
Checked ssh keys
---
$ ssh -T [email protected]
Hi <username>! You've successfully authenticated, but GitHub does not provide shell access.
---
Still receiving the same message.
仍然收到相同的消息。
回答by aymericbeaumet
Instead of adding a new remote, try to change the existing one with the following command:
不要添加新的遥控器,而是尝试使用以下命令更改现有遥控器:
git remote set-url origin [email protected]:<username>/demo_app.git
Edit: so, here are the commands to make it work without losing your code.
编辑:所以,这里有一些命令可以让它在不丢失代码的情况下工作。
rm -rf .gitgit init .git remote add origin [email protected]:<username>/demo_app.gitgit commit --allow-empty -m 'First commit'git push origin master
rm -rf .gitgit init .git remote add origin [email protected]:<username>/demo_app.gitgit commit --allow-empty -m 'First commit'git push origin master
回答by Ralph Cowling
If you got here because you're on a proxy
如果你来到这里是因为你是代理
Try:
尝试:
ssh -T -p 443 [email protected]
If that works then you can add settings to your ~/.ssh/configto always connect through 443:
如果可行,那么您可以向您添加设置~/.ssh/config以始终通过443以下方式连接:
Host github.com
Hostname ssh.github.com
Port 443
More info here: https://help.github.com/articles/using-ssh-over-the-https-port/
更多信息在这里:https: //help.github.com/articles/using-ssh-over-the-https-port/
回答by glamouracademy
To answer the new error: "error: src refspec master does not match any. error: failed to push some refs to '[email protected]:/demo_app0.git'
回答新错误:“错误:src refspec master 不匹配任何。错误:无法将一些引用推送到 '[email protected]:/demo_app0.git'
I found this post really helpful: src refspec master does not match any when pushing commits in git
我发现这篇文章真的很有帮助:src refspec master does not match any when push commits in git
Essentially, try add your files and committing again.
本质上,尝试添加您的文件并再次提交。
git commit -m 'initial commit'
git push origin master
git commit -m 'initial commit'
git push origin master
This worked for me!
这对我有用!

