You run git push or git pull and Git stops with this:
fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Despite the wording, your local repository is usually fine. The “origin does not appear to be a git repository” error means Git looked for a remote named origin and either couldn’t find one or couldn’t reach the URL it points at. Here’s how to work out which, and fix it in a minute or two.
Step 1: see which remotes you have
Start by listing the remotes this repository knows about:
git remote -v
There are three possible results, and each has its own fix:
- Nothing at all. The repository has no remotes. This is normal if you ran
git inityourself instead of cloning. Go to Step 2. - A remote with a different name, such as
upstreamorgithub. Git is right that there’s noorigin. Go to Step 3. - An
originwith a URL. The remote exists, but the URL is wrong or you can’t reach it. Go to Step 4.
For a fuller tour of these commands, see how to view and change remote origins in Git.
Step 2: add origin
Create the repository on GitHub, GitLab or wherever you host code, copy its URL, and add it as origin:
git remote add origin git@github.com:you/project.git
git push -u origin main
The -u flag sets origin/main as the upstream for your local main, so from now on a plain git push and git pull know where to go. If your branch is called master, use that name instead; git branch shows which you have.
Step 3: rename the remote, or use its real name
If the remote exists under another name, you have two options. Either use that name in your command:
git push upstream main
or rename it to origin so tools and tutorials that assume origin just work:
git remote rename upstream origin
If you have both a fork and the original project as remotes, keep the convention most people use: origin for your fork, upstream for the original.
Step 4: fix a wrong or broken URL
If origin is listed but still fails, look closely at the URL. Common mistakes are a typo in the user or repository name, a repository that was renamed or moved to an organisation, or a missing .git on some self-hosted servers. Set the correct URL with:
git remote set-url origin git@github.com:you/new-name.git
git remote -v
GitHub redirects renamed repositories for a while, but don’t rely on that; update the URL.
Step 5: check you can actually reach it
If the URL is right and you still see the error, it’s an access problem. Test it directly:
git ls-remote origin
For an SSH URL (git@github.com:...), check your key is loaded and accepted:
ssh -T git@github.com
A greeting with your username means SSH works. Permission denied (publickey) means your key isn’t set up or isn’t added to your account. If you’d rather not deal with keys right now, switch the remote to HTTPS and sign in with a personal access token:
git remote set-url origin https://github.com/you/project.git
For a private repository, also confirm your account actually has access to it. A repository you can’t see returns the same “does not exist” message as one that really doesn’t exist.
Running a command in the wrong folder
One more cause catches people out: running Git in the wrong directory. If you’re inside a subfolder that has its own .git (a nested repository or an accidentally initialised folder), Git uses that repository, which has no remotes. Check where Git thinks the repository root is:
git rev-parse --show-toplevel
If that isn’t the project you expected, cd to the right folder, or remove the stray .git directory if you created it by mistake.
After it’s fixed
Once git push reaches the remote, you might hit the next common error, a rejected push because the remote has commits you don’t. Git push rejected: how to fix ‘failed to push some refs’ covers that, and how to resolve Git merge conflicts helps if the pull that follows produces conflicts.

Leave a Reply
You must be logged in to post a comment.