记录git的第一次使用

 

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代码了