Search code examples
gitgithubrepositorygit-push

GitHub Error Repository Not Found


Trying to add a blank sample app for a rails tutorial to GitHub, but I get this error (apparently common, but I searched through other posts for a solution and couldn't find one that works for me).

ERROR: Repository not found.
fatal: The remote end hung up unexpectedly

I get the error both when I try what the rails tutorial suggests:

$ git remote add origin git@github.com:<username>/sample_app.git
$ git push -u origin master

and then the pretty similar prompt that the github repository I created says to try:

$ git remote add origin https://github.com/<username>/sample_app.git
$ git push -u origin master

I've been doing this from within the sample_app directory and after committing:

$ git commit -a -m "Improve the README" 
(which is the last change I made and the only one before trying to push it to github)

Help?


Solution

  • You need to create the repository on GitHub first, before you attempt to push to it. If you can't get the push to work, try:

    1. Creating the repository.
    2. Cloning the new repository from GitHub.
    3. Committing your changes locally and then pushing.

    The clone will have your remotes set properly, so that's usually an easier way to go.