将我以前公司wiki上积累的东西放出来。

第一步:确定是否存在ssh 公钥
C:\Users\zhangzhia\.ssh\id_rsa.pub //红色部分替换成自己用户名
如已存在,则跳过第二步。
第二步:生成ssh的公钥私钥
cmd 执行命令:
ssh-keygen -t rsa -C [zhangzhia@yutong.com](mailto:zhangzhia@yutong.com)
替换成自己用户名,邮箱不一定是登录gitlab的邮箱
直接回车直到成功。
C:\Users\zhangzhia.ssh\ 存在2个文件。
id_rsa id_rsa.pub
第三步:配置gitlab ssh公钥
登录公司gitlab,进入ssh keys配置界面,将 公钥id_rsa.pub 内容copy到 key中, title 任意填写,并点击 Addkey按钮。

第四步:测试SSH配置是否成功
cmd中输入命令:
ssh -T [git@dev.yutong.com](mailto:git@dev.yutong.com)
配置成功则显示如下欢迎信息。

第五步:配置git私个人标识
当你安装Git后首先要做的事情是设置你的用户名称和e-mail地址。这是非常重要的,因为每次Git提交都会使用该信息。它被永远的嵌入到了你的提交中。
在cmd中执行以下命令:
备注:user.name 设置默认显示名称。在user.email与gitlab的邮箱一样时,显示gitlab名称。否则显示user.name 设置值。
git config --global [user.name](http://user.name/) "zhangzhi"
git config --global user.email "zhangzhia@[yutong.com](http://yutong.com/)"
检查配置结果:输入命令:
git config --list

第六步:Clone项目到本地
git clone [git@dev.yutong.com](mailto:git@dev.yutong.com):yutongiot/base-service.git
网友评论