32

I created a directory, hello_git. In this directory I created a file, hello_git.py, which prints out a "Hello git!" message.

Then I made hello_git my current directory in the terminal and entered the following commands one after another in that directory:

git init
git add hello_git.py
git commit -m 'first commit'
git remote add origin git@github.com:githubaccountname/hello_git.git

When I enter the command git push origin master I get asked:

Enter passphrase for key '/home/myusername/.ssh/id_rsa':

When I enter my passphrase (which authenticates successfully using ssh -T git@github.com) I get this:

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

I don't know if this helps, but:

git remote -v

returns:

origin    git@github.com:githubaccountname/hello_git.git (fetch)
origin    git@github.com:githubaccountname/hello_git.git (push)

I have looked into answers of similar posts, but nothing seems to work:

Community
  • 1
  • 1
Bentley4
  • 10,678
  • 25
  • 83
  • 134

7 Answers7

26

Eric has already given the best answer for this question in the case that the repository does not exist, but I want to point out that:

The response pair of "Repository not found. / remote end hung up unexpectedly" is also given by GitHub when the repository does exist, but the user does not have permission to push to it.

If you're absolutely certain that the repository already exists on GitHub, make sure the account you're using has permission to push to that repository.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
jlbang
  • 1,226
  • 12
  • 14
  • 1
    Can you please elaborate how to figure out if it's a permission issue? – Zack Xu Apr 18 '13 at 11:01
  • I'd recommend using these three guides on GitHub: [What are the different access permissions?](https://help.github.com/articles/what-are-the-different-access-permissions), for repos owned by a personal account: [How do I add a collaborator?](https://help.github.com/articles/how-do-i-add-a-collaborator) and for repos owned by an organization: [How do I set up a team?](https://help.github.com/articles/how-do-i-set-up-a-team) – jlbang Oct 14 '13 at 19:59
  • Quick link would be https://github.com///settings/collaboration then add a collaborator or team and give the respective write access – LeonardChallis May 16 '17 at 12:08
22

The error message says it all

ERROR: Repository not found.

Is there a Git repository where you're looking?

You need to create the repository on GitHub first. It can't find the repository because it doesn't exist yet!

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Eric
  • 95,302
  • 53
  • 242
  • 374
  • 8
    Actually for me it was because I didn't have write permission on the repository. I was about to pull, but not push. – Ben Southall Dec 15 '15 at 09:03
6

Either the repository doesn't exist or you don't have the right permission.

More information is on Error: Repository not found.

Also, if you have multiple GitHub accounts (which is actually disallowed), you need multiple ssh keys to be stored with GitHub.

More information is on Quick Tip: How to Work with GitHub and Multiple Accounts.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Zack Xu
  • 11,505
  • 9
  • 70
  • 78
4

Did you perhaps rename your repository? If you renamed your repository on GitHub, you need to update the origin accordingly. This has happened to me once, where I renamed my repository and forgot to update the origin settings in my laptop.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Eun Woo Song
  • 750
  • 6
  • 8
  • 1
    ... which on its turn can be set through the command: `git remote set-url origin git://new.url.here`, as also stated [in this answer](http://stackoverflow.com/a/2432799/1039247). – Juliën Mar 05 '14 at 13:46
2

In my case a problem was in a wrong URL.

Instead of

https://gitlab.com/username/my_repository.git

I wrote

https://gitlab.com/username/my_repository/ (copied from a browser)

Joël Salamin
  • 3,538
  • 3
  • 22
  • 33
CoolMind
  • 26,736
  • 15
  • 188
  • 224
2

This can also happen if you've stored incorrect credentials. You can clear the repo's memory to be re-prompted on your next push with this: git config --unset credential.helper

EntangledLoops
  • 1,951
  • 1
  • 23
  • 36
0

I just encountered this same issue. If none of the other solutions work, it may be because GitHub is having problems with their SSH access, as it says on their status page (https://status.github.com/)

"We are investigating problems with repository access and some GitHub.com features. We will report back once we have more information to share."

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Jvieitez
  • 91
  • 7