Unable to push code to remote github repository

edureka@wiculty:~/project/learn-devops$ git remote add origin https://github.com/devops-17/learn-devops.git
error: remote origin already exists.
edureka@wiculty:~/project/learn-devops$ git branch -M master
edureka@wiculty:~/project/learn-devops$ git push origin master
fatal: ‘master’ 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 getting the above error while trying to push code to the github remote repository. kindly guide.

This error message describes your problem. Depending on whether you want to keep the remote currently called origin you can either use a different name for the remote repository on GitHub, or change the URL. Renaming remotes is also possible.

Try using git remote set-url origin https://github.com/devops-17/learn-devops.git to ensure your remote is set properly and then run your push command. Also, what are you trying to accomplish with the git branch -M master command? With a -m or -M option, will be renamed to . I’m not sure what you are trying to accomplish, are you looking to create a new branch?

I was thinking of renaming the remote repository as master.I know that command was not required. since nothing seems to be working I tried that option.

If the remote origin already exists then why am I not able to push the code to master?

Would you want to take look at my .git/config file to see if any entry is incorrect?

your solution finally worked. I had to tinker with .git/config file a little.

1 Like


@devops-17 :smiling_face_with_three_hearts: good work, glad you got it working.