Submit code to github using ssh

Recently, I wanted to put a project I wrote on github.
So I built a warehouse on github. A. Local project location D:/code.

Submit code locally
cd D:/code
git init
git add .
git commit -m 'first commit'
Set up a remote repository
git remote add origin [email protected]:sangyuruo/A.git
commit to remote
git push origin master

An error is reported here, you need to set the ssh key.

ssh key set
general my ssh key:
ssh-keygen -t rsa -b 4096 -C "[email protected]" -f ~/.ssh/sangyuruo_rsa


add my key:
ssh-add ~/.ssh/sangyuruo_rsa


View the content of the public key:
cat ~/.ssh/sangyuruo_rsa.pub

Add the public key to github:
deploy keys -> add deploy key

Push again successfully
git push origin master


Get the code from github
git pull origin master

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326355399&siteId=291194637