• 欢迎访问显哥博客,本网站纯属学习技术,绝无商业用途,欢迎小伙伴们共同学习!研究技术!QQ:52249909 加我QQ
  • 世界75亿人,这么小的概率,能认识你,是我一生的幸运,不妨加个QQ接触一下:52249909 加我QQ

代码上线——Gitlib分支【显哥出品,必为精品】

Gitlib lixian 4年前 (2020-05-12) 20602次浏览 0个评论 扫描二维码
文章目录[隐藏]

八、分支保护

1.设置不允许普通用户master推送仓库

代码上线——Gitlib分支【显哥出品,必为精品】

2.普通用户登录

代码上线——Gitlib分支【显哥出品,必为精品】

代码上线——Gitlib分支【显哥出品,必为精品】

3.普通用户设置秘钥

[root@dev01 ~/tlbb]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:0qgnmlRDJBMyAF8cfuEnVIRhLIW6jEchfCv49Q3RvEQ root@dev01
The key's randomart image is:
+---[RSA 2048]----+
|O +o+=*OE        |
|.=.B+++.+        |
|..oo+.+o..       |
|..oo...=.        |
| =.oo.ooS        |
|. =. o...        |
| .. o .          |
| . o o           |
|  o              |
+----[SHA256]-----+
[root@dev01 ~/tlbb]# cat /root/.ssh/
id_rsa       id_rsa.pub   known_hosts  
[root@dev01 ~/tlbb]# cat /root/.ssh/id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC/ykeOue7gmKQg1jqYJ96d8gLWrC4GMVYFfDRsHUFB2wj4T2KvD4oLfTpa3HT4m2PbQpKlNR4vWfhIbbvCCp+o7/l6ZIAb5RnABG+czfAN4+1qaxtgAYfKCaxF0MISfUqvwrk979Ut9guJTJV+Yj+OcXeHQSYM0JTuYD8RRuVWr8SXAxdidvR+waicqospyZrHWYS+5Hyw0S/tk6UcTFU/EPhugU3Ff9sZGwpgphRyk5xUPgXRGXE2xlTsZucyngrRPb8aPe92k7er2zenwmRTiYsMgjhZB8TyumChsMR0MKwm7VqzOQuA79sanNNNVQ6U8ypJA7J3KeeTH65uUh/v root@dev01

代码上线——Gitlib分支【显哥出品,必为精品】

3.普通用户使用普通分支推送仓库

[root@dev01 ~]# yum install -y git
[root@dev01 ~]# git config  --global   user.name  "dev01"
[root@dev01 ~]# git config  --global   user.email "1@qq.com"
[root@dev01 ~]# git config  --global   color.ui true
[root@dev01 ~]# mkdir tlbb
[root@dev01 ~]# cd tlbb/
[root@dev01 ~/tlbb]# git init
Initialized empty Git repository in /root/tlbb/.git/
[root@dev01 ~/tlbb]# touch test.txt
[root@dev01 ~/tlbb]# git add *
[root@dev01 ~/tlbb]# git commit -m "add test.txt file"
[test 6b8e787] add test.txt file
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 test.txt
[root@dev01 ~/tlbb]# git branch
* master
  test
[root@dev01 ~/tlbb]# git branch -d test
warning: deleting branch 'test' that has been merged to
         'refs/remotes/origin/test', but not yet merged to HEAD.
Deleted branch test (was 6b8e787).
[root@dev01 ~/tlbb]# git branch
* master
[root@dev01 ~/tlbb]# 
[root@dev01 ~/tlbb]# git branch test
[root@dev01 ~/tlbb]# git branch
* master
  test
[root@dev01 ~/tlbb]# git checkout test
D	dev01.log
Switched to branch 'test'
[root@dev01 ~/tlbb]# git branch
  master
* test
[root@dev01 ~/tlbb]# git push -u origin test    #使用test分支推送
Counting objects: 6, done.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 449 bytes | 0 bytes/s, done.
Total 4 (delta 1), reused 0 (delta 0)
remote: 
remote: To create a merge request for test, visit:
remote:   http://10.0.0.100/Dev/tlbb/merge_requests/new?merge_request%5Bsource_branch%5D=test
remote: 
To git@10.0.0.100:Dev/tlbb.git
 * [new branch]      test -> test
Branch test set up to track remote branch test from origin.

代码上线——Gitlib分支【显哥出品,必为精品】

如果使用master分支会报错,因为我们设置了分支保护

[root@dev01 ~/tlbb]# touch 4.txt
[root@dev01 ~/tlbb]# git add *
[root@dev01 ~/tlbb]# git commit -m "add 4.txt file"
[master ac2b32a] add 4.txt file
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 4.txt
[root@dev01 ~/tlbb]# git push -u origin master
Counting objects: 3, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 221 bytes | 0 bytes/s, done.
Total 2 (delta 1), reused 0 (delta 0)
remote: GitLab: You are not allowed to push code to protected branches on this project.
To git@10.0.0.100:Dev/tlbb.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@10.0.0.100:Dev/tlbb.git'

九、合并分支

1.新建合并分支

代码上线——Gitlib分支【显哥出品,必为精品】

2.选择合并指向

代码上线——Gitlib分支【显哥出品,必为精品】

3.填写合并信息

代码上线——Gitlib分支【显哥出品,必为精品】

4.管理员点击Merge确认合并

代码上线——Gitlib分支【显哥出品,必为精品】

5.查看是否合并

代码上线——Gitlib分支【显哥出品,必为精品】


本站博主 , 版权所有丨如未注明 , 均为原创
转载请注明原文链接:代码上线——Gitlib分支【显哥出品,必为精品】
喜欢 (0)

您必须 登录 才能发表评论!