Thibaud Clement Thibaud Clement - 5 months ago 57
Git Question

Git push: "fatal 'origin' does not appear to be a git repository - fatal Could not read from remote repository."

I know similar questions have already been asked.

But, I believe my issue is due to a mistake I have previously made and therefore is different: let me explain.

Everything was working smoothly, as I could:

  • git add .
    all the files from my local repository.

  • git commit -m "message here"
    to add messages to my commits.

  • git push origin master
    to upload my files to GitHub.

  • git push heroku master
    to upload my files to Heroku.

However, at some point, I created a new branch locally called
in case next steps of the app development would go south...

... which is exactly what happened.

However, despite many attempts, I did not manage to get the initial code — i.e. the code from before I created the new branch — from the
branch to my local repository.

So, I decided to manually delete all the files from my local repository and
git clone
branch from GitHub.

This way, I got all my files back, but now, I cannot push any more to the remote repository.

Any time I try to run
git push origin add-calendar-model
git push origin master
, I get the following error:

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.

I am not very comfortable with Git and GitHub, as you may have guessed by now, and I have to admit that I have no clue about how to fix this.

Any idea?


First, check that your origin is set by running

git remote -v

If this returns with no output, skip to last code block.

This should show you all of the push / fetch remotes for the project.

If this returns showing that you have remotes set, check that the name of the remote matches the remote you are using in your commands.

$git remote -v
myOrigin ssh:// (fetch)
myOrigin ssh:// (push)

# this will fail because `origin` is not set
$git push origin master

# you need to use
$git push myOrigin master

If you rant to rename it, or change the URL, remove it, and then add the correct one.

$git remote remove myOrigin

You can then add in the proper remote

$git remote add origin ssh://

# this will now work as expected
$git push origin master