版本控制gitlab

版本控制gitlab

  1. 版本控制介绍

版本控制是指对软件开发过程中各种程序代码、配置文件及说明文档等文件变更的管理,是软件配置管理的核心思想之一。

版本控制最主要的功能就是追踪文件的变更。它将什么时候、什么人更改了文件的什么内容等信息忠实地了记录下来。每一次文件的改变,文件的版本号都将增加。除了记录版本变更外,版本控制的另一个重要功能是并行开发。软件开发往往是多人协同作业,版本控制可以有效地解决版本的同步以及不同开发者之间的开发通信问题,提高协同开发的效率。并行开发中最常见的不同版本软件的错误(Bug)修正问题也可以通过版本控制中分支与合并的方法有效地解决。
具体来说,在每一项开发任务中,都需要首先设定开发基线,确定各个配置项的开发初始版本,在开发过程中,开发人员基于开发基线的版本,开发出所需的目标版本。当发生需求变更时,通过对变更的评估,确定变更的影响范围,对被影响的配置项的版本进行修改,根据变更的性质使配置项的版本树继续延伸或产生新的分支,形成新的目标版本,而对于不受变更影响的配置项则不应发产生变动。同时,应能够将变更所产生的对版本的影响进行记录和跟踪。必要时还可以回退到以前的版本。例如当开发需求或需求变更被取消时,就需要有能力将版本回退到开发基线版本。在曾经出现过的季度升级包拆包和重新组包的过程中,其实就是将部分配置项的版本回退到开发基线,将对应不同需求的不同分支重新组合归并,形成新的升级包版本。
版本控制是软件配置管理的核心功能。所有置于配置库中的元素都应自动予以版本的标识,并保证版本命名的唯一性。版本在生成过程中,自动依照设定的使用模型自动分支、演进。除了系统自动记录的版本信息以外,为了配合软件开发流程的各个阶段。还需要定义、收集一些元数据来记录版本的辅助信息和规范开发流程,并为今后对软件过程的度量做好准备。当然如果选用的工具支持,这些辅助数据将能直接统计出过程数据,从而方便软件过程改进活动的进行。对于配置库中的各个基线控制项,应该根据其基线的位置和状态来设置相应的访问权限。一般来说,对于基线版本之前的各个版本都应处于被锁定的状态,如需要对它们进行变更,则应按照变更控制的流程来进行操作。

常用的版本控制工具:

  • gitlab
  • subversion

gitlab配置

关闭防火墙和selinux

[root@localhost ~]# systemctl --now stop firewalld
[root@localhost ~]# systemctl disable firewalld
[root@localhost ~]# setenforce 0
[root@localhost ~]# vim /etc/selinux/config 
[root@localhost ~]# cat /etc/selinux/config 

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted


[root@localhost ~]# reboot

配置yum源

# 配置阿里云源
[root@localhost yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
[root@localhost yum.repos.d]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
[root@localhost yum.repos.d]# 
[root@localhost yum.repos.d]# yum clean all
27 files removed
[root@localhost yum.repos.d]# yum makecache

# 配置epel源
[root@localhost yum.repos.d]# yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm
[root@localhost yum.repos.d]# sed -i 's|^#baseurl=https://download.example/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*
[root@localhost yum.repos.d]# sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*
[root@localhost yum.repos.d]# yum clean all
[root@localhost yum.repos.d]# yum makecache

下载依赖包

[root@localhost ~]# yum -y install git curl openssh-server openssh-clients postfix cronie python3-policycoreutils.noarch  

启动并且开机自启postfix服务

[root@localhost ~]# systemctl restart postfix
[root@localhost ~]# systemctl enable postfix
Created symlink /etc/systemd/system/multi-user.target.wants/postfix.service → /usr/lib/systemd/system/postfix.service.

下载gitlab的rpm包

[root@localhost ~]# yum -y install perl
[root@localhost ~]# rpm -qa| grep  policycoreutils
python3-policycoreutils-2.9-16.el8.noarch
policycoreutils-python-utils-2.9-16.el8.noarch
policycoreutils-2.9-16.el8.x86_64
[root@localhost ~]# yum -y remove python3-policycoreutils policycoreutils-python-utils policycoreutils  
[root@localhost ~]# wget http://mirror.centos.org/centos/7/os/x86_64/Packages/policycoreutils-python-2.5-34.el7.x86_64.rpm

安装gitlab

[root@localhost ~]# ll
total 1265900
-rw-------. 1 root root       1246 Jul 27 09:41 anaconda-ks.cfg
-rw-r--r--  1 root root 1295805808 Sep 28 12:01 gitlab-ce-16.4.1-ce.0.el7.x86_64.rpm
// 下载包到本地在上传
-rw-r--r--  1 root root     468316 Apr  3  2020 policycoreutils-python-2.5-34.el7.x86_64.rpm
[root@localhost ~]# rpm -ivh --nodeps policycoreutils-python-2.5-34.el7.x86_64.rpm 
warning: policycoreutils-python-2.5-34.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:policycoreutils-python-2.5-34.el7################################# [100%]
[root@localhost ~]# rpm -ivh gitlab-ce-16.4.1-ce.0.el7.x86_64.rpm 
warning: gitlab-ce-16.4.1-ce.0.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f27eab47: NOKEY
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:gitlab-ce-16.4.1-ce.0.el7        ################################# [100%]
It looks like GitLab has not been configured yet; skipping the upgrade script.

       *.                  *.
      ***                 ***
     *****               *****
    .******             *******
    ********            ********
   ,,,,,,,,,***********,,,,,,,,,
  ,,,,,,,,,,,*********,,,,,,,,,,,
  .,,,,,,,,,,,*******,,,,,,,,,,,,
      ,,,,,,,,,*****,,,,,,,,,.
         ,,,,,,,****,,,,,,
            .,,,***,,,,
                ,*,.
  


     _______ __  __          __
    / ____(_) /_/ /   ____ _/ /_
   / / __/ / __/ /   / __ `/ __ \
  / /_/ / / /_/ /___/ /_/ / /_/ /
  \____/_/\__/_____/\__,_/_.___/
  

Thank you for installing GitLab!
GitLab was unable to detect a valid hostname for your instance.
Please configure a URL for your GitLab instance by setting `external_url`
configuration in /etc/gitlab/gitlab.rb file.
Then, you can start your GitLab instance by running the following command:
  sudo gitlab-ctl reconfigure

For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md

Help us improve the installation experience, let us know how we did with a 1 minute survey:
https://gitlab.fra1.qualtrics.com/jfe/form/SV_6kVqZANThUQ1bZb?installation=omnibus&release=16-4

修改配置文件

[root@localhost ~]# vim /etc/gitlab/gitlab.rb
##! address from AWS. For more details, see:
##! https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
external_url 'http://192.168.136.139' //将这设置成gitlab主机的ip

## Roles for multi-instance GitLab

查看配置文件并 重启gitlab

[root@localhost ~]# yum -y install libselinux-utils
[root@localhost ~]# getenforce
Disabled
[root@localhost ~]# gitlab-ctl reconfigure
.....过程省略
following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.

gitlab Reconfigured! (成功)
[root@localhost ~]# gitlab-ctl restart
ok: run: alertmanager: (pid 11754) 1s
ok: run: gitaly: (pid 11762) 0s
ok: run: gitlab-exporter: (pid 11776) 0s
ok: run: gitlab-kas: (pid 11788) 0s
ok: run: gitlab-workhorse: (pid 11796) 0s
ok: run: logrotate: (pid 11807) 0s
ok: run: nginx: (pid 11813) 0s
ok: run: node-exporter: (pid 11820) 1s
ok: run: postgres-exporter: (pid 11825) 0s
ok: run: postgresql: (pid 11851) 0s
ok: run: prometheus: (pid 11854) 0s
ok: run: puma: (pid 11872) 1s
ok: run: redis: (pid 11877) 0s
ok: run: redis-exporter: (pid 11885) 1s
ok: run: sidekiq: (pid 11893) 0s

查看当前的gitlab版本

[root@localhost ~]# head -1 /opt/gitlab/version-manifest.txt
gitlab-ce 16.4.1

查看密码

[root@localhost ~]# cd /etc/gitlab/
[root@localhost gitlab]# ll
total 168
-rw------- 1 root root 144854 Oct  7 04:42 gitlab.rb
-rw------- 1 root root  19057 Oct  7 04:50 gitlab-secrets.json
-rw------- 1 root root    749 Oct  7 04:50 initial_root_password
drwxr-xr-x 2 root root      6 Oct  7 04:50 trusted-certs
[root@localhost gitlab]# cat initial_root_password 
# WARNING: This value is valid only in the following conditions
#          1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run).
#          2. Password hasn't been changed manually, either via UI or via command line.
#
#          If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.

Password: lhYiVRFmXyqn2wteWiJ6nFEtVyuAoi0iotGH1LYNcBY=

# NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.
[root@localhost gitlab]# 

可以去网页登入用上面的密码password
在这里插入图片描述在这里插入图片描述在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

破解管理员密码

[root@localhost ~]# gitlab-rails console --help
Usage:
  rails console [options]

Options:
  -e, [--environment=ENVIRONMENT]  # Specifies the environment to run this console under (test/development/production).
  -s, [--sandbox], [--no-sandbox]  # Rollback database modifications on exit.


[root@localhost ~]# gitlab-rails console --help
Usage:
  rails console [options]

Options:
  -e, [--environment=ENVIRONMENT]  # Specifies the environment to run this console under (test/development/production).
  -s, [--sandbox], [--no-sandbox]  # Rollback database modifications on exit.


[root@localhost ~]# gitlab-rails console -e production
--------------------------------------------------------------------------------
 Ruby:         ruby 3.0.6p216 (2023-03-30 revision 23a532679b) [x86_64-linux]
 GitLab:       16.4.1 (e6801ed8d44) FOSS
 GitLab Shell: 14.28.0
 PostgreSQL:   13.11
-----------------------------------------------------------[ booted in 223.05s ]
Loading production environment (Rails 7.0.6)
irb(main):001:0> 
Loading production environment (Rails 7.0.6)
irb(main):001:0> user = User.where(id: 1).first    //id为1的是超级管理员
=> #<User id:1 @root>
irb(main):002:0> user.password = 'tq12345!'   //密码必须至少8个字符
=> "tq123!"
irb(main):003:0> user.password_confirmation = 'tq12345!'
=> "tq123!"
irb(main):004:0> user.save
=> true
irb(main):005:0> exit (退出)

页面登入
在这里插入图片描述
在这里插入图片描述
gitlab管理

在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述
在这里插入图片描述

如果没有像上面这张图一样勾选了Initillize repository with a README 这个选项的
如下:
[root@localhost ~]# git config --global user.name "root"
[root@localhost ~]# git config --global user.email "1@1234com"
[root@localhost ~]# git clone http://192.168.136.139/root/test-project.git
Cloning into 'test-project'...
Username for 'http://192.168.136.139': root
Password for 'http://root@192.168.136.139': 
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), 2.78 KiB | 2.78 MiB/s, done.
[root@localhost ~]# 

# 创建主分支
[root@localhost ~]# ls
anaconda-ks.cfg  gitlab-ce-16.4.1-ce.0.el7.x86_64.rpm  policycoreutils-python-2.5-34.el7.x86_64.rpm  test-project
[root@localhost ~]# cd test-project/
[root@localhost test-project]# ls
README.md
[root@localhost test-project]# git switch --create main

# echo 一个test文件
[root@localhost test-project]# echo "hello world" > test
[root@localhost test-project]# ll
total 12
-rw-r--r-- 1 root root 6179 Oct  7 07:40 README.md
-rw-r--r-- 1 root root   12 Oct  7 07:46 test

# 添加并且提交
[root@localhost test-project]# git add test
[root@localhost test-project]# git commit -m "first commit"
[main ac9b4c9] first commit
 1 file changed, 1 insertion(+)
 create mode 100644 test
# 传给主机
[root@localhost test-project]# git push --set-upstream origin
Username for 'http://192.168.136.139': root
Password for 'http://root@192.168.136.139': 
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 2 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 266 bytes | 266.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To http://192.168.136.139/root/test-project.git
   7853898..ac9b4c9  main -> main
Branch 'main' set up to track remote branch 'main' from 'origin'.
[root@localhost test-project]# 

在这里插入图片描述如果想上传文件
在这里插入图片描述创建组
在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述创建用户
在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述
加入组里面
在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述
在这里插入图片描述在这里插入图片描述退出!登入ttq用户

![在这里插入图片描述](https://img-blog.csdnimg.cn/823867957fd746b9953de02e0ec85b4a.png#pic_center
在这里插入图片描述
在这里插入图片描述在这里插入图片描述在这里插入图片描述创建文件
在这里插入图片描述在这里插入图片描述
在这里插入图片描述再次登入root用户,给权限
在这里插入图片描述

安装时报错:

安装gitlab的时候存在依赖关系:

[root@localhost ~]# rpm -ivh gitlab-ce-16.4.1-ce.0.el7.x86_64.rpm 
warning: gitlab-ce-16.4.1-ce.0.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f27eab47: NOKEY
error: Failed dependencies:
	perl is needed by gitlab-ce-16.4.1-ce.0.el7.x86_64
	policycoreutils-python is needed by gitlab-ce-16.4.1-ce.0.el7.x86_64

解决方法:

[root@localhost ~]# yum -y install perl
[root@localhost ~]# rpm -qa| grep  policycoreutils
python3-policycoreutils-2.9-16.el8.noarch
policycoreutils-python-utils-2.9-16.el8.noarch
policycoreutils-2.9-16.el8.x86_64
[root@localhost ~]# yum -y remove python3-policycoreutils policycoreutils-python-utils policycoreutils
[root@localhost ~]# wget http://mirror.centos.org/centos/7/os/x86_64/Packages/policycoreutils-python-2.5-34.el7.x86_64.rpm
[root@localhost ~]# rpm -ivh --nodeps policycoreutils-python-2.5-34.el7.x86_64.rpm 
[root@localhost ~]# rpm -ivh gitlab-ce-16.4.1-ce.0.el7.x86_64.rpm 

这个问题可能是由于删除的时候误删了文件或者包

[2023-10-07T04:44:21-04:00] FATAL: Stacktrace dumped to /opt/gitlab/embedded/cookbooks/cache/cinc-stacktrace.out
[2023-10-07T04:44:21-04:00] FATAL: ---------------------------------------------------------------------------------------
[2023-10-07T04:44:21-04:00] FATAL: PLEASE PROVIDE THE CONTENTS OF THE stacktrace.out FILE (above) IF YOU FILE A BUG REPORT
[2023-10-07T04:44:21-04:00] FATAL: ---------------------------------------------------------------------------------------
[2023-10-07T04:44:21-04:00] FATAL: Errno::ENOENT: execute[semodule -i /opt/gitlab/embedded/selinux/rhel/7/gitlab-7.2.0-ssh-keygen.pp] (gitlab::selinux line 20) had an error: Errno::ENOENT: No such file or directory - se

解决方法:

[root@localhost ~]# yum -y install libselinux-utils
[root@localhost ~]# getenforce
Disabled
[root@localhost ~]# gitlab-ctl reconfigure
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值