How to Fix Fatal: Origin Does Not Appear to Be a Git Repository Error in Git

John Wachira Feb 02, 2024
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.

  1. Your remote fork (origin) might be missing.
  2. 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.

fatal error in git

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.

  1. On your GitHub account, go to Repositories and select the repository you want to link your local repo.

    GitHub Repositories

  2. Click on Code and copy the link to your repository.

    copy link

  3. 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.

git push

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.

Author: John Wachira
John Wachira avatar John Wachira avatar

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.

LinkedIn

Related Article - Git Error