0

I have a public key with GitHub. Just made it today. I closed Git and launched it back again and now its not pushing my projects. It generates the following error:

Permission denied (publickey). fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

As well when I try executing the following command: git remote add origin I get the following message: fatal: remote origin already exists.

Can someone please help. I have spent a lot of time trying to use suggested solutions on here, but none worked for me. Lastly, do I need to initialize Git to my public key directory and make sure access is successful to GitHub every time I launch Git?

1 Answers1

1

The error 'fatal: remote origin already exists' means that you have already done

git remote add origin 'your git repo'

To remove the origin, do this:

git remote rm origin

And redo the command:

git remote add origin 'your git repo'

Example:

git remote add origin https://github.com/YourUsername/YourProject.git

Also make sure that the repository exists and is created on GitHub, and you have access to it.

Andrew Li
  • 55,805
  • 14
  • 125
  • 143
  • Thank you so much. It worked. I removed the origin and redid the command but instead of using git@github.com:/UserName/Project.git, I used what you gave me: https://github.com/YourUsername/YourProject.git – Ahmed Aldhaheri Apr 23 '16 at 04:34
  • In the place of YourUsername and YourProject, you put your github username and your github project. An example could be mine: `git remote add origin https://github.com/Li357/SudokuSolver.py` And if I you could be willing, give me a thumbs and the selected answer :) – Andrew Li Apr 23 '16 at 04:35
  • what I meant is gitHub gives the following command: git remote add origin git@github.com:UserName/Project.git. instead I used: git remote add origin https://github.com/UserName/Project.git. instead of git@github.com I used what you gave me https://github.com – Ahmed Aldhaheri Apr 23 '16 at 04:39
  • I gave you thumbs up, but since I am new its saying it wont show until I earn 15 points. I guess I have to go answer some easy programming questions to earn those points lol – Ahmed Aldhaheri Apr 23 '16 at 04:40
  • Sure, so if you could give me the repository you are trying to add as a remote I could give you the command to type. You can select it as the best answer :) – Andrew Li Apr 23 '16 at 04:40