Solve GitHub push error 403 Forbidden while accessing

The business scenario

I originally created a Repository on Github, called Github_test, and Uploaded some files. But in a few years, I want to use the Repository again, update and upload files.

I clone the Repository on a virtual machine, modify and add some files, and want to update to Github.

Here’s how I did it

I created the public and private keys using SSH-Keygen,


The public key

The cat ~ /. SSH/id_rsa. Pub

To submit to Github, here are the steps


But I encountered the following error on Git Push:

git push

error: The requested URL returned error: 403 Forbidden while accessing https://github.com/taoyunxing/github_test/info/refs

fatal: HTTP request failed

The solution

vim .git/config

Modify the

[remote “origin”]

url =
https://github.com/taoyunxing/github_test

To:

[remote “origin”]

url =
https://[email protected]/taoyunxing/github_test

Git push again, enter the password for the entire Github account in the pop-up box, and you can commit


conclusion

Here’s a hint:

Any repository I have on Github, and if I want to commit code on some new terminal machine and I forget about the public key, I can generate a pair of public and private keys locally, upload the public key to the repository, and happily push git code.

reference

[1].
http://blog.csdn.net/happyteafriends/article/details/11554043

Read More: