git ssh

git bush先生成ssh公钥,生成的文件默认在C盘用户的.ssh里。

拿出来,到hub,ee,lab上去配一个ssh公钥。

第一次连接需要 ssh -T git@gitee.com

再git clone xxx.git

正常的gitlab项目,我们从服务器上获取项目的clone地址,如下图。


在本地运行clone命令,将项目代码从服务器远程仓库克隆到本地仓库。

$ git clone git@gitlab57.zy.com:eiis/est.git
但是,如果gitlab服务器的SSH使用了非22端口号,会出现以下错误,无法clone项目。

Cloning into 'E:gitProjectest'...
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
出现这个错误并不是输错了密码,或者SSH的公钥、私钥不配对,或者没项目的读取权限,而是因为gitlab服务器的SSH使用了非22端口号。

遇到这种情况,需要修改项目的clone地址,使用如下格式(假设SSH端口号为2222):

$ git clone ssh://git@gitlab57.zy.com:2222/eiis/est.git

原文地址:https://www.cnblogs.com/zhuxiang1029/p/15474362.html