ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDI5yMQBjSftxN9PHg3ogCwaTxPNZ3n5+TZRwJZBKO5sQGNirAzNdq8wFwbUFqtFDqYFxU3mTBh5LG3Fk1Zh8R8abpzmHijP09gdgB4Ae31axRAPcngXss//flKQCSHoQlvwI+ZWozMGItmFMcmRCla4BTq/e3mVJuIdR8VQwSG32SeRqReZIrjbvsa8hp3D5nbLa5KWRiAuOj4OhPBwHOG8hx/wSnplyI8rtMayj6BjuczDdrZNotyv0IntxFZPoUQJ/+pN1azHGm6tI1TmKyh1lmmc5Tu0a7TxTf7Ve+P/srbxlqb7CWT168fZRzziglXcR5e2Ge7tNrkXo+dl2tf root@gitlab-client
将上面的公钥文件复制到gitlab中
ssh key添加完成
点击项目,查看项目的ssh地址及http地址
按照项目下面的提示进行简单配置
在客户端操作
git全局设置
[root@gitlab-client ~]# git config --global user.name "test" #配置使用Git仓库的人员姓名
[root@gitlab-client ~]# git config --global user.email "test@test.com" #配置使用Git仓库的人员email
设置后提交记录才会在gitlab上显示带名字的记录
[root@gitlab-client ~]# git config --list #检查配置信息
3.4 导入新项目文件到仓库
[root@gitlab-client ~]# cd /service/tools/jeesns/
[root@gitlab-client jeesns]# rm -rf .git #在网站下载的jeesns有.git目录,删除该目录
[root@gitlab-client jeesns]# git init #初始化仓库(创建一个名为 .git 的子目录,这个子目录含有你初始化的 Git 仓库中所有的必须文件,这些文件是 Git 仓库的骨干)
初始化空的 Git 版本库于 /service/tools/jeesns/.git/
[root@gitlab-client jeesns]# git remote add origin git@10.0.0.5:root/jeesns.git #添加远程项目地址(可从项目主页复制)
[root@gitlab-client jeesns]# git add . #将修改保存到索引区
[root@gitlab-client jeesns]# git commit -m "tijiao" #提交所有代码到本机的版本库
[root@gitlab-client jeesns]# git push -u origin master #将本地的更改提交到远程服务器
The authenticity of host '10.0.0.5 (10.0.0.5)' can't be established.
ECDSA key fingerprint is b7:9c:07:5c:a0:01:c3:00:50:f4:59:8e:e3:f5:f5:e2.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.0.0.5' (ECDSA) to the list of known hosts.
Counting objects: 1932, done.
Compressing objects: 100% (1851/1851), done.
Writing objects: 100% (1932/1932), 37.69 MiB | 9.26 MiB/s, done.
Total 1932 (delta 283), reused 0 (delta 0)
remote: Resolving deltas: 100% (283/283), done.
To git@10.0.0.5:root/jeesns.git
* [new branch] master -> master
分支 master 设置为跟踪来自 origin 的远程分支 master。
此时查看项目,代码已经成功上传到gitlab