sudo apt install git
git config --global user.name "Your Name"
git config --global user.email "email@example.com"
然后我们可通过命令 git config --list
,查看是否设置成功。
查看home目录下是否有.ssh目录,一般情况是没有的,需要我们敲命令生成这个目录,在终端输入
ssh-keygen -t rsa -C "youremail@example.com"
然后一路按回车,其实就是不设置密码。
Your identification has been saved in /home/zxx/.ssh/id_rsa.
Your public key has been saved in /home/zxx/.ssh/id_rsa.pub.
cat ~/.ssh/id_rsa.pub
进入.ssh目录你会看到两个文件id_rsa和id_rsa.pub,id_rsa是私钥,id_rsa.pub自然就是 公钥啦。
然后我们需要做的就是把id_rsa.pub文件中的内容拷贝一下。
进入你自己的github,进入Settings->SSH and GPG keys->New SSH key,然后在Key那栏下面将拷贝的东西粘贴进去就可以了,最后点击 Add SSH key按钮添加。
XanderCheung
#1楼