How to Fix Fatal: Origin Does Not Appear to Be a Git Repository Error in Git
This article outlines the steps necessary to solve the fatal: 'origin' does not appear to be a git repository
error in Git. This error is associated with the git push origin <branch-name>
command.
Here are some of the most probable causes of the fatal: 'origin' does not appear to be a git repository
error.
- Your remote fork (
origin
) might be missing. - Your remote’s URL configuration might have changed.
If you initialize a local repo with the git init
command and fail to link the repo with a remote repository, you will get the same error if you attempt to push the changes.
Fix the fatal: 'origin' does not appear to be a git repository
Error in Git
We now know why this error pops up on Git. How do we fix it?
We first need to check if our local repository has an origin
. We will run the command below.
$ git remote -v
If you can’t see the origin
listed in the output, your origin
remote repo might be missing, or you did not link your local repo with a remote repository.
To set it up, go to your GitHub account where the remote repository is located and follow the steps below.
-
On your GitHub account, go to
Repositories
and select the repository you want to link your local repo. -
Click on
Code
and copy the link to your repository. -
On the Git terminal, run the command below to add
origin
to your repo.$ git remote add origin<URL>
In our case:
$ git remote add origin https://github.com/Wachira11ke/Git-Tutorials.git
As shown below, we can run the git branch
command to check for remote branches in our repo.
$ git branch -a
Output:
* master
remotes/origin/master
As shown below, we can now push our code by running the git push origin master
command.
The command above will push to our origin
and create a branch called master
.
If the issue persists, your URL might not be referenced correctly. We can run the command shown below to rectify this issue.
$ git remote set-url origin ssh://git@github.com/gitusername/newRepositoryName.git
You can also change your master
to origin
if the above methods do not help. Just run:
$ git pull origin master
In conclusion, we have covered three methods you can use to solve the error mentioned above on Git. Always link a local repo with a remote repo before pushing code.
John is a Git and PowerShell geek. He uses his expertise in the version control system to help businesses manage their source code. According to him, Shell scripting is the number one choice for automating the management of systems.
LinkedInRelated Article - Git Error
- How to Fix: Git Is Not Recognized as an Internal or External Command Error
- How to Resolve Git Status Unmerged Paths
- Bower: ENOGIT Git Is Not Installed or Not in the PATH
- How to Fix Another Git Process Seems to Be Running in This Repository Error
- How to Fix Fatal: The Current Branch Master Has No Upstream Branch Error in Git