无法推送到github,ssh:无法解析主机名

我无法通过这个,重新编译数据库多次,使SSH密钥

--------------
demo_app <username>$ git remote add origin git@github.com:<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 git@github.com

Hi <username>! You've successfully authenticated, but GitHub does not provide shell access.

---

仍然收到相同的消息。


尝试使用以下命令更改现有的远程设备,而不是添加新的远程设备:

git remote set-url origin git@github.com:<username>/demo_app.git

编辑:所以,这里是使它工作而不会丢失你的代码的命令。

  • rm -rf .git
  • git init .
  • git remote add origin git@github.com:<username>/demo_app.git
  • git commit --allow-empty -m 'First commit'
  • git push origin master

  • 如果你来到这里是因为你在代理上

    尝试:

    ssh -T -p 443 git@ssh.github.com
    

    如果这样做,那么你可以添加设置到你的~/.ssh/config始终通过443连接:

    Host github.com
      Hostname ssh.github.com
      Port 443 
    

    更多信息在这里:https://help.github.com/articles/using-ssh-over-the-https-port/


    要回答新的错误:“错误:src refspec master不匹配任何错误:未能将某些参考文献推送到'git@github.com:/demo_app0.git'

    我发现这篇文章真的很有用:在git中推送提交时,src refspec master不匹配任何内容

    本质上,尝试添加你的文件并再次提交。

    git commit -m 'initial commit' git push origin master

    这对我有用!

    链接地址: http://www.djcxy.com/p/48961.html

    上一篇: Cannot push to github, ssh: Could not resolve hostname

    下一篇: src refspec ~ does not match any