Intro
Repository not found error when pushing to github usually means that Git is unable to locate the repository you are trying to access or work with. This error can occur for various reasons, and the solution depends on the specific circumstances.
Most Common Causes
Some of the most common causes for this error will be highlighted below:
- The repository does not exist: Make sure that the repository you are trying to push to actually exists. You can check by running the following command in your CLI:
git remote –v
You should see the URL of the remote repository if it exist, it looks like this bashhttps://github.com/USERNAME/REPONAME’
-
You do not have access to the repository: If the repository is private, you need to be added as a collaborator and given ‘read and write’ access. You can check your access by trying to clone the repository. If you get an error message, you do not have access to the repository.
-
The remote origin is incorrect: The remote origin is the URL of the remote repository that you are trying to connect to. If the remote origin is incorrect, you will get an error message. You can check the remote origin by running command in step 1. Then check the spelling of the repository URL. Typos are a common cause of this error.
Solutions
If you have followed all of the steps above and you confirmed that the repository exist, you have read and write access to the repository and the remote origin is also correct and you are still getting the fatal: repository not found error, you can try this solutions below:
Clear All Github Accounts from Windows Credential
If you use git on windows, try to clear your credentials by following these following steps:
- Press window key + R
- Type control and hit enter
- Click on User Account
- Click credential manager
- Click windows Credentials tab
- Remove any credentials with github
Authenticate with Personal Access Token
Github recommends that you use token-based authentication, such as personal access token or fine-grained personal access token for HTTPS Git operations on GitHub and if your repository uses an SSH remote URL you will need to switch the remote from SSH to HTTPS To solve the problem, follow these steps:
- Check if the remote origin exists by running the following command:
git remote -v
- Remove the remote origin by running the following command:
git remote remove origin
-
Generate a personal access token. Here are the instructions
-
Re-add the remote origin by running the following command:
git remote add origin https://username:generated-token@github.com/username/reponame.git
- Push your project to the remote repository by running the following command:
git push -u origin master/main
NOTE: If you run into a problem after following these steps, make sure your token is not expired. If it is, regenerate your token and repeat step 4 above.