Push & pull problemsAlways fixable

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 found
ERROR: 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.

quick fix
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

  1. 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 1
    ssh -T git@github.com
    # 'Hi <username>!' - is that the account with access?
    
    git config user.email
    git remote -v
    
  2. Clear 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 2
    git credential reject <<< $'protocol=https\nhost=github.com\n'
    
    # macOS Keychain:
    git credential-osxkeychain erase <<< $'protocol=https\nhost=github.com\n'
    
    Show the Windows version
    Windows
    cmdkey /list | findstr github
    # then remove it in Control Panel -> Credential Manager -> Windows Credentials
    git config --global credential.helper manager
    
  3. Check 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 3
    git 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 it
    
  4. Confirm 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 4
    curl -H "Authorization: token <YOUR_TOKEN>" https://api.github.com/user
    curl -H "Authorization: token <YOUR_TOKEN>" https://api.github.com/repos/owner/repo
    

    A 404 from the API for a repository you can see in the browser confirms the token is the problem.

  5. 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 yes
    

    Then 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 clone

Copy a remote repository, its full history and its branches, onto your machine.

git remote

Manage the named URLs your repository syncs with.

git credential / credential.helper

Stop Git asking for your username and password on every push.

git ls-remote

List a remote's branches and tags without cloning it.

git config

Read 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

← All Git Rescue guides