配置SSH Key连接GitLab

Git配置ssh连接相关命令:

1、配置账号

$ git config —global user.name "cwh"

$git config —global user.email "cwh@xxx.com"

邮箱需要GitLab上账号配置相对应的邮箱,否则拉取、或者更新不了项目代码

2、生成 SSH 密钥

$ ssh-keygen -t rsa -C “cwh@xxx.com

2.1 查看ssh公钥

$cat id_rsa.pub

2.2 ssh存放路径

~/.ssh

2.3在GitLab账号中心设置SSH Keys

3、克隆项目

$git clone git@xxx.git

或者项目涉及包含子项目则执行下面的命令

$git clone git@xxx.git --recursive

3.1测试ssh连接

$ssh -T git@xxx.git

3.2将克隆的项目直接拖到SoureTree进行打开

【参考】

  1. 使用SSH连接到GitHub
  2. GitLab配置ssh key
  3. sourceTree 添加 ssh key 方法
  4. sourceTree 添加 ssh key 方法
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容