15

I can't get pass this, have remade the repository multiple times, made ssh keys over

--------------
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.

---

Still receiving the same message.

MikO
  • 18,243
  • 12
  • 77
  • 109
A Ali
  • 297
  • 2
  • 3
  • 8

3 Answers3

16

Instead of adding a new remote, try to change the existing one with the following command:

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

Edit: so, here are the commands to make it work without losing your code.

  1. rm -rf .git
  2. git init .
  3. git remote add origin git@github.com:<username>/demo_app.git
  4. git commit --allow-empty -m 'First commit'
  5. git push origin master
aymericbeaumet
  • 6,853
  • 2
  • 37
  • 50
  • tried that before, turns out i didn't do $ git add . before, I tried to create what i did before to get the error message but I got a diff error "error: src refspec master does not match any. error: failed to push some refs to 'git@github.com:/demo_app0.git' – A Ali May 14 '13 at 16:52
6

If you got here because you're on a proxy

Try:

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

If that works then you can add settings to your ~/.ssh/config to always connect through 443:

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

More info here: https://help.github.com/articles/using-ssh-over-the-https-port/

Ralph Cowling
  • 2,839
  • 1
  • 20
  • 10
0

To answer the new error: "error: src refspec master does not match any. error: failed to push some refs to 'git@github.com:/demo_app0.git'

I found this post really helpful: src refspec master does not match any when pushing commits in git

Essentially, try add your files and committing again.

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

This worked for me!

Community
  • 1
  • 1
glamouracademy
  • 103
  • 2
  • 8