1.输入 ls -al ~/.ssh,检查是否显示有id_rsa.pub或者id_dsa.pub存在 。存在则跳到第三步。
第一次操作的时候 出现以下显示:
$ ls -al ~/.ssh
total 16
drwxr-xr-x 1 Admin 197609 0 5月 7 13:35 ./
drwxr-xr-x 1 Admin 197609 0 5月 7 13:35 ../
第二次查询的时候出现:
2.输入 ssh-keygen -t rsa -C "123456789@qq.com" (引号内填写自己的邮箱地址)
出现下图
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Admin/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/Admin/.ssh/id_rsa.
Your public key has been saved in /c/Users/Admin/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:LsxBJPni2XeG2gTgIXl8STECFKLlGEjburcvg4E5AQQ ”yourEm123456789@qq.com
The key's randomart image is:
+---[RSA 2048]----+
|E+==oo=o |
|+*= *+o. |
|+..= =. |
|. . o.o |
|.+ . +..S. |
|+.. oo.o+ o |
| oo. +=.o |
| ..o. ... |
| .+. |
+----[SHA256]-----+
3.打开id_rsa.pub文件,并且复制全部内容 (可查看第二步已把文件地址明确显示出来。C/用户/Admin/.ssh.id_rsa.pub) 用记事本打开即可。
4.登录githab 选择用户设置
SSH添加完成。
5接下来就是通过ssh链接克隆开发的仓库代码.在githab里面找到要复制的代码路径。
用 Git Bash 输入命令
$ git clone git@gitlab.infoepoch.com:cmsn/xx-test.git
点回车 出现以下 ,第一次链接ssh会提示确认链接,输入yes,点回车即可。
Cloning into 'epms-sn'...
The authenticity of host 'gitlab.xx.com (47.110.137.167)' can't be established.
ECDSA key fingerprint is SHA256:ozcEzPvQ3kUEquHmdkAY7KrB/axXy7KDd/hsKXPqX7I.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'gitlab.xx.com,47.110.137.167' (ECDSA) to the list of known hosts.
remote: Enumerating objects: 8968, done.
remote: Counting objects: 100% (8968/8968), done.
remote: Compressing objects: 100% (4878/4878), done.
Receiving objects: 4% (376/8973), 18.38 MiB | 133.00 KiB/s
执行完成之后,代码就克隆下来了。
6.打开 vs 可查看链接
注意事项: 完成以上操作之后,我的vs不能拉取、提取和同步,并且右下角无功能显示。vs版本是2015,改成http链接也不行。所以我就在软件管理 查询到vs2017 .,点击下载,按照步骤一直安装即可。在打开vs,右下角就出现功能,并且可以正常使用同步功能。
接下来到这,基本可以正常使用。