Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
+3 votes
3 views
in DevOps and Agile by (29.3k points)
edited by

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 add-calendar-model in case the next steps of the app development,

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 master branch to my local repository.

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

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

Any time I try to run git push origin add-calendar-model or 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?

3 Answers

+5 votes
by (50.2k points)

This error occurs due to the remote is not added so what you could do is:

git remote -v

git remote remove <present remote name>

Then add 

git remote add <remote-name(ie:- origin)> <githuburl>

Then you could do: 

git push origin master

 So that this will work. Hope this will help you.

Also, these 18 Git commands that are frequently used while working with Git will help you learn everyday development process.

Git push: fatal: 'origin' does not appear to be a git repository - fatal Could not read from remote repository.
Intellipaat-community
by (29.3k points)
Thank you this works for me.
by (19.7k points)
This worked for me as well!
by (33.1k points)
This answer was helpful.
Thanks!
by (47.2k points)
A similar error appears while pulling the changes from the origin. If you are trying in Intellij from the menu options, the pull might not work directly. Go to terminal and type this command and this should work out:
git pull origin master
by (19.9k points)
Worked for me.
by
this was so much helpful, thank u
+1 vote
by (107k points)

As @yeshwanth.intelli stated above

However, the origin might not be set, so skip the deleting step and simply attempting to add can clear this up.

git remote add origin <"clone"

Where "clone" is just going into your GitHub repo and copying the "HTTPS clone URL" and pasting into GitBash

Git push: fatal: 'origin' does not appear to be a git repository - fatal Could not read from remote repository.
Intellipaat-community
by (29.5k points)
Nice observation !
by (44.4k points)
This sounds doable, good answer
0 votes
by (106k points)

The error occurs because sometimes you don't have a local REF for pushing that branch back to the origin. So in those cases, you can try:-

git push origin master:master

This explicitly indicates which branch to push to and from where.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...