008. gitlab代码克隆与推送
推送配置
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提交合并请求:
微信赞赏
支付宝赞赏