git配置ssh

1、设置git的user name和email,执行以下命令:


 git config --global user.name "xxx"
 git config --global user.email "[email protected]"

设置完成后可以执行以下命令检查设置结果:

git config --global  --list 

结果如下:

user.name=xxx

[email protected]

2、生成秘钥:

 

执行以下命令:

 ssh-****** -t rsa -C "[email protected]"

一直回车即可(也可以根据自己情况设置)

  1. 确认秘钥的保存路径
  2. 如果上一步置顶的保存路径下已经有秘钥文件,则需要确认是否覆盖
  3. 创建密码
  4. 确认密码

记录git的第一次使用

3、添加公钥到你的远程仓库(github)

1、查看公钥:

跳转到上一步的保存路径下然后执行:

cat ~/.ssh/id_rsa.pub

可以看到公钥内容

记录git的第一次使用

2、登陆github帐户。点击头像,点击 Settings -> 左栏点击 SSH and GPG keys -> 点击 New SSH key

3、然后你复制上面的公钥内容,粘贴进“Key”文本域内。 title域,自己随便起个名字。

4、点击 Add key。

记录git的第一次使用

 添加成功后邮箱会收到邮件提示。

 

至此就基本设置完了,可以clone你需要的代码了

通过ssh获取代码:

复制需要clone代码的ssh路径[email protected]:xxxx.git

执行以下命令

 git clone [email protected]:xxxx.git

记录git的第一次使用

这样本地就完成clone代码了

相关文章:

  • 2021-08-09
  • 2021-08-30
  • 2022-01-01
  • 2021-11-10
  • 2022-12-23
  • 2022-12-23
  • 2021-11-15
  • 2022-12-23
猜你喜欢
  • 2021-11-06
  • 2022-03-07
  • 2021-07-28
  • 2021-06-01
  • 2021-10-13
  • 2021-06-29
  • 2021-12-15
相关资源
相似解决方案