10

I created a repository on GitHub called 'messages' and a local repository with the same name. I am trying to push the files from my local repo to the remote but get this error:

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

I figured it was an authentication issue. And when I ran

ssh -T git@github.com

I did get a message indicating that my key did not work. So I added my ~/.ssh/github_rsa.pub to the SSH keys in my account on GitHub (deleted the one that already existed there) and ran the command again. This time I received a message saying -

Hi septerr! You've successfully authenticated, but GitHub does not provide shell access.

From what I read this seemed to be the expected message. So, I again tried the push. But received same error. Repository not found.

Swapnas-MacBook-Pro:messages sony$ git remote -v show
origin  git@github.com:seterr/messages.git (fetch)
origin  git@github.com:seterr/messages.git (push)
Swapnas-MacBook-Pro:messages sony$ git push -u origin master
ERROR: Repository not found.
fatal: The remote end hung up unexpectedly

When I look at my repo on GitHub I see:

Existing Git Repo?
cd existing_git_repo
git remote add origin git@github.com:septerr/messages.git
git push -u origin master

What could be wrong?

random
  • 9,774
  • 10
  • 66
  • 83
septerr
  • 6,445
  • 9
  • 50
  • 73

9 Answers9

14

If you are receiving this error and a typo is not the cause, as was my scenario, try opening .git/config and deleting the section:

[remote "origin"]   
url = git@github.com:yourgitusername/my_project.git  
fetch = +refs/heads/*:refs/remotes/origin/*

Then rerun the following (replace 'yourgitusername'):

git remote add origin git@github.com:yourgitusername/my_project.git   
git push -u origin master

This resolved the problem for me. Credit to this answer on a similar question: Git Push ERROR: Repository not found

Community
  • 1
  • 1
ShaunUK
  • 929
  • 6
  • 17
9

I had the same problem. My issue was misunderstanding that I had to first create the empty repo on github before pushing to it. Doh! Including this here for anyone else who doesn't realize.

Nate Barr
  • 4,640
  • 2
  • 25
  • 21
6

Your remote address is, compared to what github tells you:

 git@github.com:seterr/messages.git    <== your remote
 git@github.com:septerr/messages.git   <== GitHub actual repo address

You forgot the 'p' in septerr.

As mentioned in "GitHub pushing/pulling error", GitHub repo addresses are sensitive to typo or case.


Nick mentions in the comments:

I ran into an issue where I needed to change my repo address due to a change in GitHub username.
Here's the code for it:

git remote set-url origin git@github.com:username/reponame.git 

This will set the remote name to origin with the GitHub username of username.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    I ran into an issue where I needed to change my repo address due to a change in GitHub username. Here's the code for it: `git remote set-url origin git@github.com:username/reponame.git` - This will set the remote name to `origin` with the GitHub username of `username`. – Nick May 14 '12 at 19:50
  • @Nick good point. I have included your comment in the answer for more visibility. – VonC May 14 '12 at 20:25
  • "Sensitive" to typo, actually. We French tend to mistake the two words for one another ^^ – Kheldar Feb 19 '14 at 11:09
  • `git remote set-url origin https://github.com/[USERNAME]/[REPONAME].git` also works – xevser Feb 09 '18 at 08:26
5

If you're using OS-X on a Mac and have a HTTPS URL for your remote WITHOUT credentials then the KeyChain may be used for the credentials.

Is it possible that the credentials in your KeyChain are incorrect? Perhaps you have changed your password or you have two github accounts but the wrong one is being used?

If in doubt open the KeyChain app and remove the "github.com" entries then when you next perform a fetch/pull/push etc you will be re-prompted for your github username and password.

All the above assumes that you had previously enabled 'Password/Keychain Caching' as per the guide at https://help.github.com/articles/set-up-git#platform-mac

Oliver Pearmain
  • 19,885
  • 13
  • 86
  • 90
1

I also had this issue and it turned out to be that I hadn't granted the user access to the repo so the error message was a bit misleading.

Reece Marsland
  • 256
  • 1
  • 5
1

This might help someone, when you add your ssh key to Github, you must add to your profile settings on your user account instead of the repository deploy key.

If you have multiple private repository, this will work for all of them. I did make a mistake by add my ssh key to one of private repository, so when I try to clone the other repository, I got the error "Repository not found..."

Fin
  • 61
  • 3
0

I contacted github support and they told me to check my git credentials in Windows Credential Manager if I am using a windows machine. Seems that somehow the git credentials were incorrect. I corrected the credentials and push worked.

Anuvrat Tiku
  • 1,616
  • 2
  • 17
  • 25
0

This is an old post, but I figured I would add an update in case anyone looking at this thread experienced a similar problem and was looking for a fix. I also got a "repository not found" error after successfully logging in; the problem was not due to a typo, but because I hadn't properly defined the scope of my personal access token. If you log in to GitHub using 2FA, you need to use a personal access token in lieu of a password when using the command line. When creating that token, make sure you go down the checklist and give the token the proper scope to read/write to repositories. Otherwise, you'll be able to log in but won't be able to do much else.

More on Scopes at GitHub: https://developer.github.com/apps/building-oauth-apps/scopes-for-oauth-apps/

-2

The problem is username after colon (:). You should use slash and then it works:

git clone ssh://git@github.com/USERNAME/REPONAME.git

The semicolon stands for PORT not username in ssh urls.

git clone ssh://git@gitgub.com:22/REPONAME.git

Mitja Gustin
  • 1,723
  • 13
  • 17