'Could not read/write from/to remote repository
I am getting that error when I tried to push commits to Github:
remote: Write access to repository not granted.
fatal: unable to access 'https://github.com/...../...../':
The requested URL returned error: 403
Also there are similar errors you may get for the same reaon. For example:
Initialized empty Git repository in `/Users/username/Documents/cakebook/.git/`
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
And so on..
Solution 1:[1]
To solve this problem follow these steps (If you are trying to clone repository as HTTPS or you already cloned HTTPS and trying to push the changes to the Github):
1-) git remote -v
run this command on terminal and you'll see something like that:
origin https://github.com/career-karma-tutorials/ck-git (fetch)
origin https://github.com/career-karma-tutorials/ck-git (push)
2-) git remote set-url origin [email protected]:career-karma-tutorials/ck-git then run this. You'll write your github repo instead of career-karma-tutorials/ck-git
We are doing this because we will use SSH instead of HTTPS for cloning the repository.
3-)ssh-keygen then run this. You will see these:
Enter file in which to save the key (C:\Users\asasa/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your public key has been saved in C:\Users\asasa/.ssh/id_rsa.pub.
The key fingerprint is:
Just press enter for all these (You can do this security stuff if you want but I am skipping it)
Then you'll see an image like this:
The key's randomart image is:
+---[RSA 3542]----+
| =*--B. |
| o+=-=++. |
| o.+---o. |
| . o.+= o. |
| ..= S=. |
| *+ -o. . . |
| .o+. . E |
| ..* . |
| +.* |
+----[SHA126]-----+
4-) cat C:\Users\asasa/.ssh/id_rsa.pub. Then you will run this. (""C:\Users\asasa/.ssh/id_rsa.pub."" this part is same with the one in the 3th step)
After run this you'll see a huge text (that's your key). Copy it and go to Github/settings/keys press new SSH key and paste your key in key section.
Then go back to terminal and make your push or clone. It will work!:)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Emirhan Selim Uzun |
