2

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 [email protected]:<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?

2
  • What is the output from git status, git log, git remote -v and git branch -avv? Commented Jun 15, 2012 at 21:01
  • Have you defined your public key? Commented Jun 15, 2012 at 21:50

3 Answers 3

2

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.

Sign up to request clarification or add additional context in comments.

3 Comments

I did! It exists, which is why I'm so perplexed.
git clone https://github.com/sashafklein/sample_app; cd sample_app; git remote -v works fine for me.
So what would that mean? Does that mean it worked and I don't need to do anything? Or that there's something wrong with my computer/my rails install?
1

Another reason this can happen: when you connect to a remote server, the ssh keys are not loaded. To get around this, you can set up forwarding in ~/.ssh/config:

Host * ForwardAgent yes 

This will ensure that when you connect to github from another server, that your keys stay loaded.

Comments

0

One of the weird things about doing these operations on a Windows machine is that Windows credentials Manager can cache your GitHub username and password, and that always gets sent across the wire, even when you hard-code your u/p right into the URL. Going into Windows Credentials Manager and clearing the GitHub account credentials can sometimes help.

enter image description here

Five other common reasons for encountering the git fatal: repository not found error include:

  1. You did not authenticate
  2. Your password has changed
  3. You are not a collaborator
  4. Incorrect case or a word misspelled
  5. The git repository has been deleted

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.