Can’t Clone a Private GitHub Repo? Here’s the Fix

Why it happens

When you clone a private repository, you may see:

remote: Repository not found. fatal: repository ‘https://github.com/your-username/your-repo.git/’ not found

The repository usually does exist. GitHub returns “not found” for a private repo when the account Git is signed in with doesn’t have access to it. A common cause is that your terminal’s Git uses a different saved GitHub account from the one VS Code is signed in with.

Option 1: Clone through VS Code Easiest

  1. Press Ctrl+Shift+P, type Git: Clone and choose Clone from GitHub.
  2. Pick your repository from the list.
  3. When asked where to save it, choose your project folder.

This uses VS Code’s own GitHub sign-in. If the repo isn’t in the list, the account VS Code is signed in with doesn’t have access to it.

Option 2: Sign the terminal in with the right account

Check which GitHub account Git Credential Manager has saved:

git credential-manager github list

If it shows the wrong account, sign that account out, then clone again:

git credential-manager github logout <account-name>
git clone https://github.com/your-username/your-repo.git

A browser window will open so you can sign in. Use the account that owns the repository or has been added as a collaborator.

Tip: If a failed clone left a folder behind, Git will say destination path already exists and is not an empty directory. Delete the leftover folder first. In PowerShell, run Remove-Item -Recurse -Force your-repo.