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提交合並請求:


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM