fatal: 'origin' does not appear to be a git repository — your repository has no remote
called origin, so Git could not find anywhere to push. Add it with
git remote add origin <url> and push with
git push -u origin main. If the message quotes a URL or path instead of the word
origin, the remote exists but points somewhere that is not there.
git remote -v tells you which case you are in: an empty answer means no remote at all,
a line with a wrong URL means a typo to correct with git remote set-url.
The error
$ git remote -v
$ git push -u origin main
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.
The second cause, a remote added with a typo in its path, quotes the path:
$ git remote add origin ../blg.git
$ git push -u origin main
fatal: '../blg.git' 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.
Both exit with code 128, and Windows PowerShell 5.1 printed the first one word for word.
Why it happens
In git push -u origin main, origin is the name of a remote, a saved
URL. git init creates a repository with no remotes, so a push command copied without
the git remote add line before it fails. When no remote has that name, Git treats the word
itself as a path. The test proved it: with a bare repository made in a folder literally called
origin, the same git push origin main succeeded and printed
To origin, with git remote -v still empty. Without such a folder, the
word origin is a path that does not exist, hence the message.
Other ways to land here: the remote was added under another name, such as
upstream, or it was removed. A plain git push with no remote at all
gives a different message, fatal: No configured push destination., with the same
cure.
The fix
No remote: add it, then push with -u:
$ git remote add origin ../origin.git
$ git remote -v
origin ../origin.git (fetch)
origin ../origin.git (push)
$ git push -u origin main
branch 'main' set up to track 'origin/main'.
To ../origin.git
* [new branch] main -> main
$ git push
Everything up-to-date
A remote with a wrong path or URL: correct it, then push:
$ git remote set-url origin ../blog.git
$ git push -u origin main
branch 'main' set up to track 'origin/main'.
To ../blog.git
* [new branch] main -> main
-u records origin/main as the upstream of your main, which
is why the plain git push afterwards knew where to go. git ls-remote --heads
origin listed refs/heads/main on the remote. With a hosted remote, use the URL
the hosting site shows for the repository and compare it with git remote -v character
by character; a URL that is wrong in the same way gets the same treatment.
How it was reproduced
Git for Windows 2.45.2 (git version 2.45.2.windows.1) in Git Bash 5.2.26, with a
cross-check in Windows PowerShell 5.1. No network was used: local bare repositories stood in for
the hosted remote, so the output shows paths such as ../origin.git where you would see
a URL. Each test repository was made with git init -b main and given one commit
before the push. The personal global config was replaced by an empty file
(GIT_CONFIG_GLOBAL).
Frequently asked
- How do I fix 'origin does not appear to be a git repository'?
- Run git remote -v. If it prints nothing, add the remote with git remote add origin followed by the repository URL, then push with git push -u origin main. If it prints a wrong URL, fix it with git remote set-url origin.
- Why does git push say 'Could not read from remote repository'?
- Git could not reach a repository at the remote's address. Either no remote with that name exists, so Git tried the name as a path, or the saved URL or path points to something that does not exist or that you cannot access.
- What does git push -u origin main do?
- It pushes the local main branch to the remote called origin and records origin/main as its upstream, so later a plain git push or git pull on main knows where to go.
More decoded errors in the Fixes category. Pushed a second
branch without -u? That one is
the current branch has no upstream
branch.