Search code examples
gitgithubsshssh-keygen

Repo not found fatal error while using git and unable to push to github


I've checked stackoverflow a lot trying to figure out why I could be receiving this error because I do have a repo on github for what I am trying to push to. I even regenerated my ssh key and added it to github. I also see:

Please make sure you have the correct access rights

and the repository exists.

When I try to add the repo remotely I see:

$ git remote add origin git@github.com:<username>/<reponame>.git
> fatal: remote origin already exists.

$ git push

fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

git push --set-upstream origin master

Then I get the error

When I try

ssh -T git@github.com

I see the correct username

Not sure what else to try.


Solution

  • If you have already typed

    $ git remote add origin git@github.com:<username>/<reponame>.git
    

    you can not type it again, because origin is exist now. And it will respond

    fatal: remote origin already exists.

    but the address which link to origin may wrong. Try to type

    $ git remote remove origin
    

    and type

    $ git remote add origin git@github.com:<username>/<reponame>.git
    

    again.

    Then type

    $ git push origin master
    

    If both the address and SSH key are correct, it may work.