当前位置: 首页 > news >正文

完整教程:分布式版本控制系统Gitlab

完整教程:分布式版本控制系统Gitlab

目录

一、环境

二、部署

1. 开启邮件服务

2. 添加YUM源

3. 安装gitlab

4. 查看gitlab版本

三、配置

1.  配置登录接口

2. 配置smtp邮件通知

3. 初始化启动

4. 发送邮件测试

5. 浏览器登录

(1)修改密码

(2)取消用户自动注册功能(安全)

(3)修改中英文皮肤

​编辑四、创建项目

五、开发机克隆远程仓库

六、上传Markdown帮助文档

七、新建分支

验证


一、环境

关闭防火墙和SELINUX

主机名IP地址系统版本
gitlab-server192.168.159.133CentOS Stream release 9

二、部署

1. 开启邮件服务

yum install -y postfix && systemctl start  postfix && systemctl enable postfix

2. 添加YUM源

(1)官方源:

 curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash

(2)清华源:

[root@gitlab-sever ~]# vim  /etc/yum.repos.d/gitlab-ce.repo
[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
gpgcheck=0
enabled=1

3. 安装gitlab

yum -y install gitlab-ce  #自动安装最新版

4. 查看gitlab版本

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

三、配置

1.  配置登录接口

[root@gitlab-sever ~]# grep "192.168.159.133" /etc/gitlab/gitlab.rb 
external_url 'http://192.168.159.133'

2. 配置smtp邮件通知

[root@gitlab-sever ~]# grep "gitlab_rails" /etc/gitlab/gitlab.rb | grep -v "^#"
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.qq.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "2126177631@qq.com"
gitlab_rails['smtp_password'] = "pbdvpdxauvwvfddi"
gitlab_rails['smtp_domain'] = "smtp.qq.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = false
gitlab_rails['smtp_tls'] = true
gitlab_rails['gitlab_email_enabled'] = true
gitlab_rails['gitlab_email_from'] = '2126177631@qq.com'
gitlab_rails['gitlab_email_display_name'] = 'gitlab'
gitlab_rails['gitlab_email_reply_to'] = '2126177631@qq.com'
gitlab_rails['gitlab_email_subject_suffix'] = '[gitlab]'

3. 初始化启动

[root@gitlab-sever ~]# gitlab-ctl reconfigure
[root@gitlab-sever ~]# gitlab-ctl start
[root@gitlab-sever ~]# lsof -i:80
COMMAND    PID       USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
nginx     4497       root    7u  IPv4  68812      0t0  TCP *:http (LISTEN)
nginx     4498 gitlab-www    7u  IPv4  68812      0t0  TCP *:http (LISTEN)
nginx     4499 gitlab-www    7u  IPv4  68812      0t0  TCP *:http (LISTEN)
nginx     4499 gitlab-www   16u  IPv4  67979      0t0  TCP bogon:http->bogon:58438 (ESTABLISHED)
nginx     4500 gitlab-www    7u  IPv4  68812      0t0  TCP *:http (LISTEN)
nginx     4501 gitlab-www    7u  IPv4  68812      0t0  TCP *:http (LISTEN)
gitlab-ka 4568        git    7u  IPv4  68899      0t0  TCP bogon:58438->bogon:http (ESTABLISHED)

4. 发送邮件测试

# 发送邮件
[root@gitlab-sever ~]# gitlab-rails console
--------------------------------------------------------------------------------Ruby:         ruby 3.2.8 (2025-03-26 revision 13f495dc2c) [x86_64-linux]GitLab:       18.5.1 (2e5ae10576d) FOSSGitLab Shell: 14.45.3PostgreSQL:   16.10
------------------------------------------------------------[ booted in 37.54s ]
Loading production environment (Rails 7.1.5.2)
irb(main):001> Notify.test_email('2126177631@qq.com', 'Test Subject', 'Test Body').deliver_now
net-smtp (0.3.3) lib/net/smtp.rb:1076:in `check_response':  (Net::SMTPUnknownError)from net-smtp (0.3.3) lib/net/smtp.rb:1044:in `getok'from net-smtp (0.3.3) lib/net/smtp.rb:1026:in `quit'from net-smtp (0.3.3) lib/net/smtp.rb:715:in `do_finish'from net-smtp (0.3.3) lib/net/smtp.rb:614:in `start'from config/initializers/mail_starttls_patch.rb:53:in `start_smtp_session'from mail (2.8.1) lib/mail/network/delivery_methods/smtp.rb:100:in `deliver!'from mail (2.8.1) lib/mail/message.rb:2145:in `do_delivery'from mail (2.8.1) lib/mail/message.rb:253:in `block in deliver'from actionmailer (7.1.5.2) lib/action_mailer/base.rb:600:in `block in deliver_mail'from activesupport (7.1.5.2) lib/active_support/notifications.rb:208:in `instrument'from actionmailer (7.1.5.2) lib/action_mailer/base.rb:598:in `deliver_mail'from mail (2.8.1) lib/mail/message.rb:253:in `deliver'from actionmailer (7.1.5.2) lib/action_mailer/message_delivery.rb:126:in `block (2 levels) in deliver_now'from activesupport (7.1.5.2) lib/active_support/callbacks.rb:101:in `run_callbacks'from actionmailer (7.1.5.2) lib/action_mailer/message_delivery.rb:125:in `block in deliver_now'from actionmailer (7.1.5.2) lib/action_mailer/rescuable.rb:21:in `handle_exceptions'... 17 levels...
irb(main):002>

5. 浏览器登录

[root@gitlab-sever gitlab]# cat  initial_root_password
# WARNING: This password is only valid if ALL of the following are true:
#          ? You set it manually via the GITLAB_ROOT_PASSWORD environment variable
#            OR the gitlab_rails['initial_root_password'] setting in /etc/gitlab/gitlab.rb
#          ? You set it BEFORE the initial database setup (typically during first installation)
#          ? You have NOT changed the password since then (via web UI or command line)
#
#          If this password doesn't work, reset the admin password using:
#          https://docs.gitlab.com/security/reset_user_password/#reset-the-root-password
Password: sL6X3Yc8uR7Rd4u/UMPy/zNzLTVtg5VAJ7E7NhBJsZ0=
# NOTE: This file is automatically deleted after 24 hours on the next reconfigure run.

(1)修改密码

(2)取消用户自动注册功能(安全)

(3)修改中英文皮肤

可设置时间、语言、背景等



四、创建项目

五、开发机克隆远程仓库

[root@dev ~]# git config --global user.email "2126177631@qq.com"
[root@dev ~]# git config --global user.name "ink"
从远程Git 仓库服务器克隆一个完整的代码仓库到本地
[root@dev ~]# git clone http://192.168.159.133/root/test.git
Cloning into 'test'...
Username for 'http://192.168.159.133': root      # 输入用户名
Password for 'http://root@192.168.159.133':      # 输入密码
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 (from 0)
Receiving objects: 100% (3/3), done.
# 查看仓库
[root@dev ~]# ls
anaconda-ks.cfg  test
[root@dev ~]# cd test/
[root@dev test]# ls -a
.  ..  .git  README.md

持续交付

[root@dev test]# ls -a
.  ..  .git  os_info.py  README.md
[root@dev test]# git add os_info.py
[root@dev test]# git commit -m "Version01:检查系统基础状态"
[main ba57bae] Version01:检查系统基础状态1 file changed, 115 insertions(+)create mode 100644 os_info.py
[root@dev test]# git log
commit ba57bae0870e44feef7e57bec86aa87ada79d1f9 (HEAD -> main)
Author: ink <2126177631@qq.com>
Date:   Tue Oct 28 17:51:16 2025 +0800Version01:检查系统基础状态
commit 113edcc0d93ae5f7dce339dd07973732e7fa194e (origin/main, origin/HEAD)
Author: ink <2126177631@qq.com>
Date:   Tue Oct 28 17:39:31 2025 +0800Initial commit
[root@dev test]# git branch -a
* mainremotes/origin/HEAD -> origin/mainremotes/origin/main
# 注意提交时所在的分支
[root@dev test]# git push origin main
Username for 'http://192.168.159.133': root
Password for 'http://root@192.168.159.133':
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 4 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 1.80 KiB | 1.80 MiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
To http://192.168.159.133/root/test.git113edcc..ba57bae  main -> main

六、上传Markdown帮助文档

[root@dev test]# mkdir docs
[root@dev test]# cd docs/
[root@dev docs]# vim help.md
[root@dev docs]# cat help.md
# 一、测试项目
## 1. 监控系统基础状态
(1)**CPU使用率**
(2)**内存使用率**
(3)磁盘使用率
(4)系统版本
(5)……保留选项……
[root@dev test]# git add docs
[root@dev test]# git commit -m "Version:添加docs目录及其帮助文档!"
[root@dev test]# git log
commit 7fa58cf6dd61fed6b9ad838cae7bc3de79a82a0a (HEAD -> main)
Author: ink <2126177631@qq.com>
Date:   Tue Oct 28 19:06:13 2025 +0800Version:添加docs目录及其帮助文档!
commit ba57bae0870e44feef7e57bec86aa87ada79d1f9 (origin/main, origin/HEAD)
Author: ink <2126177631@qq.com>
Date:   Tue Oct 28 17:51:16 2025 +0800Version01:检查系统基础状态
commit 113edcc0d93ae5f7dce339dd07973732e7fa194e
Author: ink <2126177631@qq.com>
Date:   Tue Oct 28 17:39:31 2025 +0800Initial commit
[root@dev test]# git push origin main

创建代码块

七、新建分支

验证

http://www.jsqmd.com/news/304627/

相关文章:

  • 2026年 全案设计/整体家居全案设计/家居全案设计/家具全案设计/实木家具全案设计/一站式全案设计服务商推荐榜单:打造理想生活空间的匠心之选
  • 2026年携程任我行礼品卡回收注意事项
  • 不用记命令!Docker Compose UI+cpolar,公网也能轻松管容器
  • 【毕业设计】基于springboot的二手滑板交易系统(源码+文档+远程调试,全bao定制等)
  • 如何选择适合你的AutoCAD版本?AutoCAD最建议用的5个版本
  • 【课程设计/毕业设计】基于springboot+Vue的飞机票预订管理系统基于springboot的机票预订系统【附源码、数据库、万字文档】
  • 【AI应用开发工程师】-RAG知识切片(chunk)策略解读
  • DHCP练习1
  • Java毕设项目推荐-基于springboot的公园游玩导航购物综合服务系统设计与实现小程序【附源码+文档,调试定制服务】
  • certbot续签
  • Java毕设项目推荐-基于SpringBoot的航空公司售票系统飞机票购票系统基于springboot的机票预订系统【附源码+文档,调试定制服务】
  • Java毕设项目推荐-基于springboot的二手商品滑板交易系统【附源码+文档,调试定制服务】
  • 2026年 北京代理记账服务深度推荐榜单:专业流程解析、透明费用对比与高效平台甄选指南
  • 【省钱攻略】一套产品图要花 3000?揭秘 AI 如何把“中文样机”直接修成“欧美大片”,摄影师都看不出真假!
  • 2026年全屋高端定制厂家推荐榜单:实木家具/整体家居/一站式定制,匠心工艺与奢华体验深度解析
  • 【转化黑科技】淘宝“买家秀”也能做亚马逊?揭秘 AI 如何批量清洗中文评论图,0 成本获取海量真实素材!
  • 【商业机密】怕新品图泄露?别再用在线翻译工具了!揭秘“离线版”AI 修图软件如何守护你的爆款 IP
  • Java毕设选题推荐:基于springboot的机票预订系统基于SpringBoot的航空公司售票系统飞机票购票系统【附源码、mysql、文档、调试+代码讲解+全bao等】
  • 【工厂出海】有货源没美工,怎么做跨境?AI 批量“洗图”神器,让 1688 工厂图直通亚马逊!
  • 【欧洲站攻略】想做亚马逊欧洲站,被“5 种语言”劝退?揭秘 AI 如何一键生成德法意西 5 国图片,让利润翻倍!
  • 【爆单密码】Listing 转化率太低?因为你少了这张“吊打同行”的对比图!AI 揭秘如何一键汉化复杂的营销图表
  • 计算机Java毕设实战-基于SpringBoot的民航网上订票系统基于springboot的机票预订系统【完整源码+LW+部署说明+演示视频,全bao一条龙等】
  • 信号处理仿真:图像信号处理_(6).图像压缩编码
  • 信号处理仿真:图像信号处理_(2).数字图像的获取与显示
  • 大数据存储解决方案:HBase、Cassandra与MongoDB对比
  • android (RK3588) 查看所有声卡
  • 智能体设计模式三
  • 2026年制粒机厂家推荐排行榜:沸腾/摇摆/旋转/湿法/干法/快速整粒机,螺杆挤压/陶瓷喷雾造粒机,球形抛丸机,多功能制粒包衣机专业解析
  • 泰林注薛氏湿热论歌诀
  • 智能体设计模式二