1

I'm new to git and anytime i try to push to my repository using "git push origin master", i get this error

git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.

i believe i must have incorrectly entered my git credentials (username or password) and the system have saved the incorrect credentials. Please how do I delete the already stored credentials so that i can be prompted to enter again my credentials when i want to push to my repository. i use Linus OS.

Thank you.

Joe
  • 49
  • 2
  • What is the origin of the repository? What does the `git remote -v` return? – Dmitry Kuzminov Aug 20 '19 at 22:38
  • Possible duplicate of [GitHub Error Message - Permission denied (publickey)](https://stackoverflow.com/questions/12940626/github-error-message-permission-denied-publickey) – phd Aug 20 '19 at 22:58
  • https://stackoverflow.com/search?q=%5Bgit%5D+Permission+denied+publickey – phd Aug 20 '19 at 22:58

2 Answers2

1

When using git over ssh, you need a public/private key pair.

  • If you already have setup a public/private key pair, it would probably be located in ~/.ssh/id_rsa.pub.
  • If you don't have that setup with GitHub, you should set that up

Alternativly, you can just push to the GitHub repository with HTTPS and your GitHub login, by doing

git remote set-url --push https://github.com/<username>/<repository>.git

and pushing the repository.

ImDaveead
  • 311
  • 3
  • 7
0

(first create a repository in git, if not created already)

This worked for me:

Step 1- git remote rm origin

Step 2-select the http option in github

step 3- run the following command again

git remote add origin https://github.com/yourdirectory/link.git

git branch -M main

git push -u origin main