Linux运维-陈雷雷


持续集成教程08_gitlab克隆与推送

admin 2019-12-24 70浏览 0条评论
首页/正文
分享到: / / / /

推送配置

gitlab需要推送的客户端sshkey添加到gitlab服务器中

node1 推送配置

centos node1:
[root@node1 ~]# cat ~/.ssh/id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCypuSLA5GOV5+mZtY86AVmKoLThC13e6vIurccVwjl/ur8vd4G5lzIhfFlzeczoln4uOWfYwptFCKxPU12/yFrmAuBuDFqIKOQndcOJceox5+UkDc3rjH419h/HIqHZtDEsqKkqLoS5mZNHuYhEKUUNmCerfLElyrtVmeV3jZ5u8zudq62kSmVxK3WmjkNSScKiDyPM5xMqAxd+SkDe/a0r2Dhj83vpNRyU1n8IMkVYJnSdhGA1tKzhArkpUVTr1jm4UGx9l+LGOwE8n3vh5eO4h4GxcB14FQs6Qqcba3PN20FtxY2rfrBBqK6qz3Gt7NXbExHWJ3Xp18/VmgJ0xMT root@node1

复制所有,然后回到网页上

添加后:

进入 node1 服务器,推送文件.

现在要将 已存在的git内容推送到gitlab
[root@node1 ~]# mkdir  /git_test
[root@node1 ~]# cd /git_test/
[root@node1 git_test]# git init
Initialized empty Git repository in /git_test/.git/

[root@node1 git_test]# touch leilei.txt
[root@node1 git_test]# echo  "aaaaaaaaaaaaaaaaaa" >>leilei.txt
[root@node1 git_test]# git add .
[root@node1 git_test]# git commit -m "7777777"
[root@node1 git_test]# git push -u origin master
[root@node1 git_test]# git push -u origin master
Username for 'http://10.0.0.63': root
Password for 'http://root@10.0.0.63': 
Counting objects: 5, done.
Writing objects: 100% (3/3), 235 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To http://10.0.0.63/root/leilei_test.git
   c3ac7cb..ad53830  master -> master
Branch master set up to track remote branch master from origin.

git clone到另一台服务器,并且使用 dev用户

为了测试,这次我将密钥配置在 dev 这个用户上,看他是否可以完成代码克隆上传操作

node2 - dev用户: 推送测试

git config --global user.name "chenleilei"
git config --global user.email "370460370@qq.com"

网页上使用dev用户来添加sshkey:
[root@node2 leilei_test]# ssh-keygen -t rsa   #命令执行后一路回车即可
[root@node2 leilei_test]# cat ~/.ssh/id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDIt10O8hoAqvSUoTDvwDuofAN6mlx1JA+p+9MYhIsaCje19SagZcoW5/Jj/pRGDaR+tFVkyF25iCtKZ+AVqhaD11tQS58zvyuVtQldLCoYyrbUxIGIsvIs+yyYb5UJG/YkrsKbhVZOO5m5H1C2NcrZNTNquHus5bdd4KdD7uQRHvdTsEGXSRJ+7HgYOUxAlVdNn6jmueRbFC1FEs+GQnbNhkWjggzMyMw0czAF/iNHscE8C7astDgme8ZdFQKrlzSU4pcu2kq4pPzvaQ6WBuIo08EfssByIVhkmIiiqn4/xtV45XPzDgethGV2l4ESwr98/RYjin9HP60XTq1k2Oxz root@node2

添加后才可以同步分支.

添加和同步gitlab远程分支:
[root@node2 leilei_test]# mkdir  /leilei
[root@node2 leilei_test]# cd /leilei/
[root@node2 leilei]# git init
Initialized empty Git repository in /leilei/.git/

[root@node2 git_test]# git remote add gitlab git@10.0.0.63:root/leilei_test.git
[root@node2 git_test]# git clone git@10.0.0.63:root/leilei_test.git

#合并到dev分支
[root@node2 leilei_test]# git push -u origin dev 
Counting objects: 4, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 288 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 1 (delta 0)
remote: 
remote: To create a merge request for dev, visit:
remote:   http://10.0.0.63/root/leilei_test/merge_requests/new?merge_request%5Bsource_branch%5D=dev
remote: 
To git@10.0.0.63:root/leilei_test.git
 * [new branch]      dev -> dev
Branch dev set up to track remote branch dev from origin.

检查dev分支:

dev提交合并请求:

文档附件:

持续集成教程07_gitlab组,用户,权限设置.pdf

最后修改:2019-12-24 06:32:26 © 著作权归作者所有
如果觉得我的文章对你有用,请随意赞赏
扫一扫支付

上一篇

发表评论

评论列表

还没有人评论哦~赶快抢占沙发吧~

博客信息

  • 文章数目 102
  • 标签数目 298
  • 运行天数
  • 最后活动

广告



文章目录