生成秘钥
ssh-keygen -t rsa -C "yourmail@gmail.com"
提交公钥
将~/.ssh/id_rsa.pub内容复制到网站上提交
创建修改~/.ssh/config
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_github
User doraemonlu
设置~/.gitconfig
[user]
email = robbie@bytedance.com
name = robbie
每次 Git 提交时都会引用这两条信息,说明是谁提交了更新,所以会随更新内容一起被永久纳入历史记录
测试成功
ssh -T git@github.com
拉取代码
git clone github.com:XXX
git clone https://github.com/XXX
git clone ssh://username@github.com:29418/XXX