111111

gitlab安装

 gitlab安装流程

官网  https://about.gitlab.com/install/#centos-7  安装流程
装之前关闭防火墙        selinux
 yum install -y curl policycoreutils-python openssh-server

curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh| bash
yum install gitlab-ee -y vim /etc/gitlab/gitlab.rb/external_url 'http://192.168.1.120' gitlab-ctl reconfigure gitlab-ctl status 安装完毕

 二. http://192.168.1.120 打开页面设置密码

三.创建组--和项目

 

 

 

 

 

 

 

四 。添加SSH key

 

 [root@node1 ~]# cat .ssh/id_rsa.pub

 

 #删除远程仓库

[root@node1 data]# git remote
[root@node1 data]# git remote remove origin

 

五。创建提交3部曲

[root@node1 data]# touch test.txt
[root@node1 data]# git add .
[root@node1 data]# git commit -m 'newfile test'
[master de646f9] newfile test
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 test.txt
[root@node1 data]# git push -u origin master
Counting objects: 3, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 215 bytes | 0 bytes/s, done.
Total 2 (delta 1), reused 0 (delta 0)
To git@192.168.1.120:test/git_data.git
   74d9a27..de646f9  master -> master
Branch master set up to track remote branch master from origin.

 

六。创建DEV用户

 

 

添加到test组

 

 

如果开发用户想推代码需要添加ssh key

[root@node2 ~]# cat .ssh/id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDDYTi+o3TMaTMqblJ8PzFK45x6psSCkxGZEtT1ZnRRBjQs1hkRdO1qZqoAswvI1Ha7eR33iQplgRUxRXR/FKfugR9xBp3iKYAElwBC2545XkPMPvERSMd8nMdDgjwqKkIOfcefBrFRBPfggCFoNlfAHUFjZIhTo3Sh30hgSTKxUzd7cpitHOoCVOHVCS/qiXgqR/VY2tzoxDEn4e82iOGN54JNUdy0n2zYXvR4WEcYg2LBVUvT+DHuD7dBPWgt4Dfi3mfbp4kLIhI/sPF6zORgtrZer6TJKVmzjSSGLiHSfAg02kgroOJ/RCu7cpgq+zQJwgPx4fjhIIQ6IqlIBav1 root@node2

 

在本机克隆仓库代码

[root@node2 git_data]# git clone git@192.168.1.120:test/git_data.git

 

开发推送代码到gitlab 但是这种有问题 不能让开发直接推送到master 需要让他推送到分支上


[root@node2 git_data]# touch file.txt
[root@node2 git_data]# git add .
[root@node2 git_data]# git commit -m 'newfile'

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'root@node2.(none)')
[root@node2 git_data]# git config --global user.email "dev@example.com"
[root@node2 git_data]#   git config --global user.name "dev"
[root@node2 git_data]# git commit -m 'newfile'
[master ef18a5a] newfile
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 file.txt
[root@node2 git_data]# git push -u origin master
Counting objects: 3, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 219 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@192.168.1.120:test/git_data.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@192.168.1.120:test/git_data.git'

 创建分支,并且把分支推送到master

[root@node2 git_data]# git checkout -b dev
Switched to a new branch 'dev'
[root@node2 git_data]# git branch
* dev
  master
[root@node2 git_data]# git push -u origin dev
Counting objects: 3, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 219 bytes | 0 bytes/s, done.
Total 2 (delta 1), reused 0 (delta 0)
remote: 
remote: To create a merge request for dev, visit:
remote:   http://192.168.1.120/test/git_data/merge_requests/new?merge_request%5Bsource_branch%5D=dev
remote: 
To git@192.168.1.120:test/git_data.git
 * [new branch]      dev -> dev
Branch dev set up to track remote branch dev from origin.

 

posted @ 2020-07-01 21:13  赵SIR  阅读(235)  评论(0编辑  收藏  举报