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 couldve been deleted. But in most cases, this is not the cause.
Instead, the repository exists, but theres usually an access-related issue or some problem with the remote origin which leads to this error. Weve 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 havent been added as a collaborator, or you dont 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 isnt an access issue. Even if youre added as a collaborator, you may not have write access which could be causing this error. This scenario is surprisingly common, so its best to check with the repo owner regarding this. Additionally, its also worth confirming that the repo hasnt 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. Heres what you can do in such cases:
cdto change directories to the local project directory.
git remote -vand check that the remote origin is accurate. Make sure there are no minor issues such as
http://in place of
https://, or using the HTTPS format when youre 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
- Alternatively, you can also remove the remote origin with the
git remote rm origincommand, then re-add it. When doing so, its worth checking that the error isnt due to an authentication issue by adding your username to the url in the following fashion:
git remote add origin https://email@example.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. Heres 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.
Heres 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 its 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 didnt authenticate, the requests were limited to 60 per hour.
The Git It Write plugin has been updated to authenticate, so the issue shouldnt be as common now. But theres 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.