[git] Git Push ERROR: Repository not found

I am having a very strange problem with git and github. When I try and push, I am getting:

git push -u origin master
ERROR: Repository not found.
fatal: The remote end hung up unexpectedly

I added the remote:

git remote add origin [email protected]:account-name/repo-name.git

Any ideas?

This question is related to git github git-push

The answer is


I was having the same issue with one of my Github Repository.

Way around:

Used SSH instead of HTTPS and then push/pull started working fine.


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.


I have the same problem.

I solved prefixing my gitlab username to the gitlab.com url, so like this: before: https://gitlab.com/my_gitlab_user/myrepo.git and after: https://[email protected]/my_gitlab_user/myrepo.git In this case will ask for the credentials again and it's done!


you have to generate ssh key and add it in your github account in settings go to your project where you clone inside that run these command.-

1-ssh-keygen -t rsa -b 4096 -C "[email protected]"

after the command you will get some options path and name can be leave empty and you can put password.

2-eval $(ssh-agent -s) .

3-ssh-add ~/.ssh/id_rsa

after this command you have to put same password that you created in 1st command

and after that you can check your default home directory or whatever directory it is showing on the terminal .pub file open and copy the key and past in github settings new ssh


Check to see if you have read-write access.

The Git error message is misleading. I had a similar issue. I had been added to an existing project. I cloned it and committed a local change. I went to push and got the ERROR: Repository not found. error message.

The person who added me to the project gave me read-only access to the repository. A change by them and I was able to push.


If your repo was working normally before, and suddenly this error pops up, most likely the reason would be that your git is authenticated as some other user, that does not have access to the repository. So, in order to push, all you need to do is, specify your correct username and password in your git command. So, a push command for a github repo would look like:

git push https://youruser:[email protected]/user/reponame.git

username and password needs to be url-escaped, so an @ should be replaced by %40, and so on.


If anybody faced the issue at github.com check if you have accepted an invitation after repo owner allowed commits to you. Until you accept invitation repo will be invisible for you. So you'll get ERROR: Repository not found.


Changing the content of the .git/config file helps as Alex said above. I experienced the same problem and I think it was because I changed my Github username. The local files could not be updated with the changes. So perhaps anytime you change your username you might consider running

git remote add origin your_ssh_link_from_github

I hope this helps ;)


Have experienced the same problem. Everything was working fine for years and then suddenly this error.

The problem turns out was that I added a deploy key for another repo to my SSH agent before my user's github SSH key (which I always used to access the repo in question). SSH agent tried the deploy key for another repo first, and GitHub for some totally unexplainable reason was saying

ERROR: Repository not found.

Once I've removed the deploy key from SSH agent, everything was back to normal.


first Create a new repository on the command line, name like Ademo.git

Create a new repository on the command line

touch README.md git init git add README.md git commit -m "first commit" git remote add origin https://github.com/your_name/Ademo.git git push -u origin master

Push an existing repository from the command line

git remote add origin https://github.com/your_name/Ademo.git git push -u origin master


That's what worked for me:

1. The Remotes

$ git remote rm origin
$ git remote add origin [email protected]:<USER>/<REPO>.git

If your SSH key is already in use on another github rep, you can generate a new one.

2. Generating a new SSH key

$ ssh-keygen -t rsa -b 4096 -C "[email protected]"

3. Addition of the key at the SSH agent level

$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/id_rsa_github

4. Add the new key to the Github repo.


If you belong to a group in Github check that you have Write Access.


You need to check your SSH access as the following:

ssh -T [email protected]

this issue was because i don't add the person response on SSH in repository, read more about SSH link-1, link-2.


Just use the SSH remote url instead of the HTTPS


I faced same error after updating my ubuntu to next version

I just deleted my sshkey on github account and then re added an sshkey to that account.


I had the same problem. Try the following:

1. Modifying the Keychain Access in Mac for git credentials solved the problem for me.
2. Resetting origin url

git remote rm origin
git remote add origin [email protected]:account-name/repo-name.git

I had the same problem using Android Studio, I was unable to push commits because of the auth error.

My working temporary solution was to use the GitHub desktop app to push my commits and it works fine.


go to your project folder then search for the .git folder, then open the config file with notepad and check if there is your link to the github repo under: [remote "origin"], if it is different then the repo in your github then just edit it, or open a new repo with the name in the in config file


I'm using Mac and I struggled to find the solution. My remote address was right and as said, it was a credentials problem. Apparently, in the past I used another Git Account on my computer and the mac's Keychain remembered the credentials of the previous account, so I really wasn't authorised to push.

How to fix? Open Keychain Access on your mac, choose "All Items" category and search for git. Delete all results found.

Now go to the terminal and try to push again. The terminal will ask for username and password. Enter the new relevant credentials and that's it!

Hope it'll help someone. I struggled it for few hours.


remote: Repository not found. can be a frustratingly misleading error message from when trying to push to an HTTPS remote where you don't have write permissions.

Check your write permissions on the repository!

Trying an SSH remote to the same repository shows a different response:

% git remote add ssh [email protected]:our-organisation/some-repository.git

% git fetch ssh
From github.com:our-organisation/some-repository
* [new branch]        MO_Adding_ECS_configs             -> ssh/MO_Adding_ECS_configs
* [new branch]        update_gems                       -> ssh/update_gems

% git push ssh     
ERROR: Repository not found.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

"The correct access rights?"

Well why didn't you say so?

It's worth noting at this point that while the SSH failure mode in this scenario is slightly better, I use HTTPS remotes over SSH because GitHub recommend HTTPS over SSH.

I understand that GitHub uses "Not Found" where it means "Forbidden" in some circumstances to prevent inadvertently reveling the existence of a private repository.

Requests that require authentication will return 404 Not Found, instead of 403 Forbidden, in some places. This is to prevent the accidental leakage of private repositories to unauthorized users.

--GitHub

This is a fairly common practice around the web, indeed it is defined:

The 404 (Not Found) status code indicates that the origin server did not find a current representation for the target resource or is not willing to disclose that one exists.

--6.5.4. 404 Not Found, RFC 7231 HTTP/1.1 Semantics and Content (emphasis mine)

What makes no sense to me is when I am authenticated with GitHub using a credential helper and I have access to that repository (having successfully cloned and fetched it) that GitHub would choose to hide its existence from me because of missing write permissions.

Checking https://github.com/our-organisation/some-repository/ using a web browser confirmed that I didn't have write permissions to the repository. Our team's GitHub administrators were able to grant my team write access in a short time and I was able to push the branch up.


This Solved my problem.

   git pull https://myusername:[email protected]/path_to/myRepo.git

Normally it happens because the project is private and you have not rights to write it. I had the same "problem" a few times, and it was for that reason. If the project it is yours, just create a private and a public key following this link: https://docs.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent and add them to the "SSH and Key" section on gitHub, then you will be able to push to the repo. In the other hand if the project it is not your, ask the owner to give you the rights for it.


I ran into the same issue and I solved it by including my username and password in the repo url:

git clone https://myusername:[email protected]/path_to/myRepo.git

I can explain how i get into the similar situation, and then will list steps that i have taken to solve this issue.

I am using
Windows 10,
git: git version 2.27.0.windows.1.

I had already setup the git and was doing git push activities. Windows Credential Manager stores the username and password so you don't have to enter username and password every git remote activities.

The encounter this problem, when i added another github account and used --local git settings. After few days, I encounter the Repository not found problem, upon investigation i found:

  1. Even if you remove the git details from Windows Credential Manager, it will save again the username, email details you enter.

So, if you are using two git accounts, you need to use (git bash as an administrator)

git config --edit --system 

and remove the

helper = manager 

line so that it is no longer registered as a credential helper. But it will ask you login details every time you do any remote activities.

How do I disable Git Credential Manager for Windows?.

To check remote origin, user details

git config --list --show-origin

git remote rm origin
git remote add origin <remote url>

I ran into the same issue on a MAC trying to pull from a private repo i was previously connected to.

I solved it by including my username in the repo url:

git remote set-url origin https://<YOUR_USER_NAME_HERE>@github.com/<YOUR_USER_NAME_HERE>/<REPO>.git

Then i was able to pull from the repo.

For a new repo you want to clone:

git clone https://<YOUR_USER_NAME_HERE>@github.com/<YOUR_USER_NAME_HERE>/<REPO>.git    

It will prompt you to enter your password to that account, you're good to go afterwards.


My solution may be useful to some of you.

I got the same error after updating my macbook's OS to Yosemite. My problem got fixed by recreating my ssh key. You can do this by following step 2 of this page: https://help.github.com/articles/generating-ssh-keys/


The following solved the problem for me.

First I used this command to figure what was the github account used:

ssh -T [email protected]

This gave me an answer like this:

Hi <github_account_name>! You've successfully authenticated, but GitHub does not provide shell access. I just had to give the access to fix the problem.

Then I understood that the Github user described in the answer (github_account_name) wasn't authorized on the Github repository I was trying to pull.


I needed to kill credential-helper processes (were multiple) and it solved the issue after providing credentials once again.

killall git-credential-cache--daemon


My code snippet:

environment {
    ...
    ...
    git_repo = 'my-repo'
}

stage ('Update Helm Chart') {
    steps {
        echo 'Updating values.xml file with latest Docker image tag'

        withCredentials([usernamePassword(credentialsId: '6bgg7dd45-c65f13-4275-a96ddehdv67gdr', usernameVariable: 'GIT_USER', passwordVariable: 'GIT_PASS')]) {
            sh '''
                git checkout ${git_branch}
                ...
                ...
                git remote set-url origin "http://${GIT_USER}:${GIT_PASS}@git.example.com/scm/${git_repo}.git"
                git push origin ${git_branch}
            '''
        }
    }
}

My Git user name was [email protected] so i had to first URL encode @ to %40. After URL encoding, my user name became deploy.user%40example.com.

However, i was still getting the following error:

fatal: repository 'http://****:****@git.example.com/scm/my-repo.git/' not found

After some trial and error, i found that if i don't use variable for user name and instead hard-code it, it works.

git remote set-url origin "http://deploy.user%40example.com:${GIT_PASS}@git.example.com/scm/${git_repo}.git"

If you clone from github using https but you are using ssh to push, you can also get this error.

To correct this, open .git/config and replace:

url = https://github.com/company/project.git

With

url = [email protected]:company/project.git

And you should be able to push with no warning...


I was getting the same error coz I change my github user name, then I do this:

git remote -v

then:

git remote set-url newname newurl 
git push -u origin master

this time I was able to push to the repository. I hope this helps.


This can also happen because GitHub itself is down. Make sure to check status.github.com to see if the problem might lie on their side.

On October 22nd 2018 you couldn't push to GitHub for several hours.


I got this error (but before was working). My problem was the missing ssh key binded with the Github account. You can check you current ssh keys with ssh-add -l.

If your key is missing, you can add it with

ssh-add ~/.ssh/your_key

Create a Fork

If don't have write access to that repository, you don't need it. Create a fork by following these instructions -- it's your own clone of the repository which you can modify freely.

After creating the fork, you can then clone that repo to your computer.

git clone [email protected]:<your-git-handle>/<repository>.git
// It will be cloned to your machine where you run the command 
// under a <repository> folder that it will create.

Checkout a new branch and make changes.

git checkout -b my-new-feature

To submit your changes to the original repository, you'll need to make sure that they're pushed

/* make changes */
git commit -am "New Feature: Made a new feature!"
git push origin my-new-feature

To get these changes into the original repository that you forked from, you can submit a Pull Requests by following these instructions. A Pull Request basically, you request that the user with write access to a repository pull down the changes you've made. Think of it like "I request that you pull my changes into your repo."


Note: Your fork will not stay up-to-date with all of the changes going on in the original repository, though. You'll have to pull down those changes periodically -- but this is easy.

After creating the fork, you can link to repo that you've forked from so that you can pull in it's changes and keep stay current.

git remote add upstream [email protected]:<git-user-handle>/<repository>.git

Once you've done that, keeping in sync with the changes made on the original repo is quite easy.

git checkout master         // checkout your local master
git pull upstream master    // fetch changes from the master branch of the repo you forked from.. which is linked to your fork under the alias "upstream" (common naming convention)
git push origin master      // push the pulled changes onto your local master
git checkout -b new-branch  // create a new branch and start making changes

I had this issue and realized I was using a different account from the one whose repo it was. Logging in as the original user resolved the issue.


If you use private repository check you connection user, it must have permission for use repository.


Had similar issue. The root of the problem was that I followed some online tutorial about adding a new repository to Github.

Just go to Github, create a new repo, it will ask you to add a README, don't add it. Create it, and you'll get instructions on how to push.

It's similar to the next two lines:

git remote add origin https://github.com/YOUR_USER/your-repo.git
git push -u origin master

One problem, that may be obvious to some that I don't see mentioned here, could be that you have access with ssh keys, but you are trying to connect your local repo to a remote via https.

If this is the case then the following commands should fix the issue for you:

$ git remote -v
origin  https://github.com/private-repo.git (fetch)
origin  https://github.com/private-repo.git (push)
$ git remote rm origin
$ git remote add origin [email protected]:private-repo.git
$ git remote -v
origin  [email protected]:private-repo.git (fetch)
origin  [email protected]:private-repo.git (push)

Note that the above works assuming that:

  1. your current remote is named origin and that you do already have a generated ssh key connected with your github account

  2. you already have an ssh key associated with your github account (and connected locally)

  3. you have the correct permissions (read/write) set on github for this repo's settings.


I was getting the same error

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

and I had created the repository on Github and cloned it locally.

I was able to solve by opening .git/config and removing the [remote "origin"] section.

[remote "origin"]   
   url = [email protected]:alexagui/my_project.git  
   fetch = +refs/heads/*:refs/remotes/origin/*

then I ran the following (again)

git remote add origin [email protected]:alexagui/my_project.git  
git push -u origin master

and this time I was able to push to the repository.


Also be sure to check whether you have desktop client installed. I double checked everything, my permission, SSH, but turns out my repo listed in the client was overriding the one I was inputting via terminal.


If you use Git on Windows, try to clear your credentials:

  1. Locate "credential manager" (should be in your Control Panel)
  2. Remove all credentials related to GitHub

enter image description here


I had the same problem, with a private repo.

do the following:

remove the remote origin

git remote rm origin

re-add the origin but with your username and pwd with writing privileges on this pvt repo

git remote add origin  https://USERNAME:[email protected]/username/reponame.git

I am having the same problem and tried many ways but at last, I have got to know that I don't have sufficient permissions to push or pull on this repo and one more way to check if you are having the permissions or not is you were not able to see settings option in that repo and if you were having permissions then you will be able to see settings option

Thanks! this is what I observed


If you include your username and the repo name we can reasonably help you, at the moment we have no reason to think the repo does actually exist.

Additionally, if the repo is private and you don't have access to it, github returns "Does not exist" to avoid disclosing the existance of private repos.

EDIT: If you're not able to clone it because it's saying it doesn't exist and it's private, it's because you're not sending authentication. Ensure that your public key is added to your keyring, or use HTTP basic auth for the time being.


The Problem: Github is not familiar with your repository from some reason.

The Error: prompted in git cli like the following:

remote: Repository not found. fatal: repository ‘https://github.com/MyOrganization/projectName.git/’ not found

The Solution : 2 Options

  1. Github might not familiar with your credentials: - The first Option is to clone the project with the right credentials user:password in case you forgot this Or generate ssh token and adjust this key in your Github. aka git push https://<userName>:<password>@github.com/Company/repositoryName.git

  2. Repo Permissions Issue with some users - In my Use case, I solved this issue when I realized I don't have the right collaborator permissions on Github in my private repo. Users could clone the project but not perform any actions on origin. In order to solve this:

Go to Repository on Github -> Settings -> Collaborators & Teams -> Add Member/Maintainer your users -> Now they got the permission to commit and push


So for me, my password had a ` (tick) in it and PhpStorm was removing the character before sending the git push:

Lets say for this example my password is _pa``ssword_

Phpstorm would output the following:

https://_username_:[email protected]/_username_/repo.git

instead of

https://_username_:_pa``[email protected]/_username_/repo.git

Changed password to something not using the ` character. WORKS!!!


To solve this problem (on Linux), I merely had to run this:

git config --global --unset credential.helper

I had a similar problem. The incorrect credentials were cached in OS X's key-chain.

Check out: https://help.github.com/articles/updating-credentials-from-the-osx-keychain


Here is how to solve my issue

#check current github account
ssh -T [email protected]

#ensure the correct ssh key used with github
ssh-agent -s
ssh-add ~/.ssh/YOUR-GITHUB-KEY

#re-add the origin
git remote add origin [email protected]:YOUR-USER/YOUR-REPO.GIT
git push -u origin master

Examples related to git

Does the target directory for a git clone have to match the repo name? Git fatal: protocol 'https' is not supported Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) git clone: Authentication failed for <URL> destination path already exists and is not an empty directory SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 GitLab remote: HTTP Basic: Access denied and fatal Authentication How can I switch to another branch in git? VS 2017 Git Local Commit DB.lock error on every commit How to remove an unpushed outgoing commit in Visual Studio?

Examples related to github

Does the target directory for a git clone have to match the repo name? Issue in installing php7.2-mcrypt How can I switch to another branch in git? How to draw checkbox or tick mark in GitHub Markdown table? How to add a new project to Github using VS Code git clone error: RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054 How to add empty spaces into MD markdown readme on GitHub? key_load_public: invalid format git - remote add origin vs remote set-url origin Cloning specific branch

Examples related to git-push

Fix GitLab error: "you are not allowed to push code to protected branches on this project"? ! [rejected] master -> master (fetch first) Git - What is the difference between push.default "matching" and "simple" error: src refspec master does not match any Issue pushing new code in Github Can't push to GitHub because of large file which I already deleted Changing the Git remote 'push to' default What does '--set-upstream' do? Git push hangs when pushing to Github? fatal: 'origin' does not appear to be a git repository