查看是否已配置了
cd ~/.ssh //进入ssh目录
看到有 id_rsa和 id_rsa.pub,说明已经有ssh 密钥。
1、如果已经有了ssh 密钥
直接复制密钥到 gitLab 上添加
pbcopy < ~/.ssh/id_rsa.pub
![](https://img.haomeiwen.com/i606270/cae72358a3c5b7d0.png)
2、配置账户
git config --global user.name "account name" //用户名,建议拼音或英文
git config --global user.email "account email" //邮箱地址
生成密钥
ssh -keygen -t rsa -C "account email" //上面的邮箱地址
连续按3次enter,不设置密码,省的以后去记得
然后就会有 id_rsa.pub 文件
![](https://img.haomeiwen.com/i606270/46037a8733ca05f5.png)
网友评论