Fix 'remote: Repository not found'
Git says 'Repository not found' but the URL is definitely right — why?
If you’re seeing this error
remote: Repository not found.fatal: repository '<url>' not foundERROR: Repository not found.You’re in the right place — the fix is below.
Short answer
On a private repository, GitHub returns 'not found' rather than 'access denied' — so this usually means you are authenticated as the wrong account, not that the repository is missing. Check who you are with ssh -T git@github.com, and clear any stale credential your helper is replaying.
ssh -T git@github.com # which account am I?
git remote -v # is the URL exactly right?
Identity first, URL second — the URL is usually fine
Does this match your situation?
- 'remote: Repository not found.' on clone, push or pull.
- The URL opens fine in a browser where you are logged in.
- It began after leaving a company, rotating a token, or adding a second GitHub account.
- A colleague can clone the same repository and you cannot.
- It worked until the repository was renamed or moved to an organisation.
Step-by-step fix
Find out who Git is logging in as
This is the step that solves it. GitHub deliberately reports a private repository you cannot see as 'not found' rather than 'forbidden', so an account with no access looks identical to a URL that does not exist.
step 1ssh -T git@github.com # 'Hi <username>!' - is that the account with access? git config user.email git remote -vClear a stale saved credential
Credential helpers cache the first token that worked and keep replaying it forever, including after it expires or loses scope. That cached value is a very common cause of a repository being 'not found' for you alone.
step 2git credential reject <<< $'protocol=https\nhost=github.com\n' # macOS Keychain: git credential-osxkeychain erase <<< $'protocol=https\nhost=github.com\n'Show the Windows version
Windowscmdkey /list | findstr github # then remove it in Control Panel -> Credential Manager -> Windows Credentials git config --global credential.helper managerCheck the URL character by character
GitHub paths are case-sensitive, and a repository that was renamed or transferred to an organisation keeps redirecting for web browsers but not always for Git. Confirm the exact owner and name.
step 3git remote -v git remote set-url origin https://github.com/CorrectOwner/correct-repo.git git ls-remote origin # succeeds only if you can actually see itConfirm your token has the right scope
A personal access token without repo scope can read public repositories and will report every private one as not found. Fine-grained tokens must additionally list the specific repository or organisation.
step 4curl -H "Authorization: token <YOUR_TOKEN>" https://api.github.com/user curl -H "Authorization: token <YOUR_TOKEN>" https://api.github.com/repos/owner/repoA 404 from the API for a repository you can see in the browser confirms the token is the problem.
Sort out multiple accounts with an SSH host alias
Two GitHub accounts on one machine constantly authenticate as the wrong one, because SSH offers the first key that works. An alias in ~/.ssh/config makes the choice explicit per repository.
step 5# ~/.ssh/config Host github-work HostName github.com User git IdentityFile ~/.ssh/id_ed25519_work IdentitiesOnly yesThen use git@github-work:org/repo.git as the remote URL and the right key is always chosen.
Why this works
GitHub, GitLab and Bitbucket all answer requests for a private repository you are not permitted to see with 'not found'. That is deliberate: replying 'access denied' would confirm the repository exists, letting anyone enumerate a company's private projects by name. The cost of that design is this error, which describes the symptom accurately and the cause not at all — the repository is there, and your credentials simply do not reach it. Once you know that, the diagnosis inverts: instead of checking the URL, check who you are authenticating as, because a stale token, the wrong SSH key or an account that lost access all produce exactly this message.
If that didn’t work
- Try cloning a public repository over the same protocol to test whether the transport works at all.
- GIT_SSH_COMMAND="ssh -v" git clone <url> shows which key SSH offered and which was accepted.
- For an organisation repository, check whether SSO authorisation is required for your token or key.
- Ask an owner to confirm your account is still a collaborator — access is often removed silently.
How to stop it happening again
- Keep work and personal accounts on separate SSH host aliases from the start.
- Use SSH keys rather than tokens where you can — no expiry, no scope to forget.
- When you rotate a token, clear the credential helper's cached copy at the same time.
- Note that renamed repositories redirect in the browser but not reliably for Git — update the remote.
Commands used in this guide
git cloneCopy a remote repository, its full history and its branches, onto your machine.
git remoteManage the named URLs your repository syncs with.
git credential / credential.helperStop Git asking for your username and password on every push.
git ls-remoteList a remote's branches and tags without cloning it.
git configRead and write Git settings for one repo, your user, or the whole machine.
Still stuck?
Search the full command reference and every other rescue guide — there are 76 of them, covering everything from detached HEAD to force-push disasters.
Browse all guides →Frequently asked questions
Why does GitHub say 'Repository not found' when it exists?
Because for a private repository you cannot access, GitHub returns 'not found' rather than 'access denied' — otherwise the error itself would confirm which private repositories exist. You are almost certainly authenticated as an account without access.
How do I check which GitHub account Git is using?
ssh -T git@github.com replies 'Hi <username>!' for SSH. For HTTPS, the account is whatever your credential helper cached, so inspect Windows Credential Manager, the macOS Keychain, or ~/.git-credentials.
Why did this start after I changed my password or token?
Your credential helper is still replaying the old one. Erase the stored entry for the host and let Git prompt again — Git never notices that a cached credential has gone stale on its own.
Does a renamed repository still work with the old URL?
The browser redirects, and Git often does too, but not reliably for every operation or every host. If the repository was renamed or transferred, update the remote with git remote set-url rather than relying on the redirect.
How do I use two GitHub accounts on one machine?
Define a Host alias in ~/.ssh/config for each, each with its own IdentityFile and IdentitiesOnly yes, then use the alias in the remote URL. Without IdentitiesOnly, SSH offers every key it has and you authenticate as whichever one is accepted first.
Related rescue guides
Git keeps saying authentication failed even though my password is correct — why?
GitHub stopped accepting account passwords over HTTPS in August 2021. You need a personal access token in place of the password, or better, switch the remote to SSH. If it worked yesterday, a cached old credential is usually the culprit — clear it and re-authenticate.
Read the fix →Always fixablegit clone or push fails with Permission denied (publickey) — how do I fix my SSH key?
The server didn't accept any key your SSH client offered. Either you have no key, the key isn't loaded into the agent, or its public half was never added to your account. Run ssh -T git@github.com to see exactly which keys are being tried.
Read the fix →Always fixablegit remote add origin fails with 'remote origin already exists' — what do I do?
This repository already has a remote called origin, usually because it was cloned or because you ran the same setup instructions twice. Check where it points with git remote -v. If it is wrong, change it with git remote set-url origin <url> rather than adding a second one.
Read the fix →Always fixableHow do I change the remote URL of a Git repository?
git remote set-url origin <new-url> repoints an existing remote. It's a purely local change — nothing on either server is touched — so it's the safe way to switch between HTTPS and SSH, move to a new host, or fix a URL after renaming the repository.
Read the fix →