When cloning a repository or pushing changes to it, you may encounter the Repository Not Found error. At first glance, the error message may give the impression that the repository might not exist or could’ve been deleted. But in most cases, this is not the cause.
Instead, the repository exists, but there’s usually an access-related issue or some problem with the remote origin which leads to this error. We’ve listed the causes in detail, as well as ways to fix this error in the sections below.
What’s Causing the Repository Not Found Error?
- The remote origin has been changed or set incorrectly.
- You haven’t been added as a collaborator, or you don’t have write access.
- Authentication issues due to the credential manager.
How to Fix Repository Not Found?
Before you start, please keep in mind that repo URLs are case-sensitive. As such, fixing this error could be as simple as adjusting the case usage.
Get Access to Repo
You should first ensure that this isn’t an access issue. Even if you’re added as a collaborator, you may not have write access which could be causing this error. This scenario is surprisingly common, so it’s best to check with the repo owner regarding this. Additionally, it’s also worth confirming that the repo hasn’t been renamed.
Check Remote Origin
If the remote origin has been changed or an incorrect value has been added, that can also cause this error. Here’s what you can do in such cases:
- Use
cd
to change directories to the local project directory. - Enter
git remote -v
and check that the remote origin is accurate. Make sure there are no minor issues such ashttp://
in place ofhttps://
, or using the HTTPS format when you’re supposed to use SSH. - If the remote origin needs to be modified, you can do so with the following command:
git remote set-url origin <RepoURL>
- Alternatively, you can also remove the remote origin with the
git remote rm origin
command, then re-add it. When doing so, it’s worth checking that the error isn’t due to an authentication issue by adding your username to the url in the following fashion:git remote add origin https://username@github.com/username/reponame.git
- This will prompt a reauthentication, and you may be asked to generate a personal access token.
Resolve Credential Issues
Outdated credentials in the system credential manager can also lead to this error, as it would cause the authentication to fail. Here’s how you can clear the git credentials on Windows:
- Press Win + R, type
control
, and press Enter. - Go to User Accounts > Credential Manager > Windows Credentials.
- Expand and remove all the git credentials.
Here’s how you can do the same on Mac:
- Press Command + Shift + U and open the Keychain app.
- Select the git keychains from the list, right-click them, or choose File > Delete keychain > Delete references.
Additionally, if you use the git credential manager, you should remove and reinstall it. You can do so with the following commands:git credential-manager uninstall
git credential-manager install
Git Request Limit
This fix is very niche, but it’s still worth mentioning. One user using the Git It Write plugin on WordPress found that this error occurred because his IP reached the API rate limit. Basically, because this plugin didn’t authenticate, the requests were limited to 60 per hour.
The Git It Write plugin has been updated to authenticate, so the issue shouldn’t be as common now. But there’s likely a limit to authenticated requests as well. If you suspect that this could be the issue in your case, you can test for it by switching to a different network or changing your IP some other way.