侧边栏壁纸
博主头像
DJ's Blog博主等级

行动起来,活在当下

  • 累计撰写 133 篇文章
  • 累计创建 51 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

【Gitlab】安装和配置

Administrator
2022-03-07 / 0 评论 / 0 点赞 / 47 阅读 / 3734 字

【Gitlab】安装和配置

安装

  • 安装依赖组件
yum -y install curl policycoreutils openssh-server openssh-clients postfix
  • 配置Postfix
vim /etc/postfix/main.cf
inet_interfaces = all
  • 启动postfix邮件服务(用于gitlab发送通知到管理者)
systemctl start postfix && systemctl enable postfix
  • 添加GitLab软件包仓库
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
  • 安装GitLab
yum install -y gitlab-ce
  • 出现以下提示表示安装成功

【Gitlab】安装和配置.png

配置

  • 配置外部访问地址
vim /etc/gitlab/gitlab.rb
external_url 'http://192.168.247.132'
  • 加载配置并重启gitlab
gitlab-ctl reconfigure
gitlab-ctl restart
  • 配置开机启动
systemctl enable gitlab-runsvdir.service
  • 常用gitlab服务指令
  1. 重新编译配置
gitlab-ctl reconfigure  
  1. 查看状态
gitlab-ctl status 
  1. 修改配置
vim /etc/gitlab/gitlab.rb 
  1. 检查gitlab
gitlab-rake gitlab:check SANITIZE=true --trace
  1. 查看日志
gitlab-ctl tail
gitlab-ctl tail nginx/gitlab_access.log

备份和还原

常见操作

代码回滚到特定版本

  • 用命令行打开git项目路径,输入git log命令查看commit记录
git log
commit c085b6a01d0521177ea0b80262a9caff9c021e34 
Author: wuxingle <1546752823@qq.com>
Date:   Thu Feb 25 08:45:03 2021 +0800

    恢复网商和平安真实余额查询

commit a2476e8a41a289200d1f083218fc2a8c8b66c708
Author: wuxingle <1546752823@qq.com>
Date:   Wed Feb 24 15:42:14 2021 +0800

    修改批次查询时排序

commit 0df4afbd99bc3fde8e519cd8aad517e0a2b6d3d1
Author: daijiong <daijiong@successhr.com>
Date:   Wed Feb 24 15:04:50 2021 +0800
  • 找到需要回滚的commit,输入git reset --hard {commitId},将本地文件回滚
git reset --hard c085b6a01d0521177ea0b80262a9caff9c021e34
HEAD is now at c085b6a0 恢复网商和平安真实余额查询
  • 此时本地文件已经回滚到刚刚commit c085b6a01d0521177ea0b80262a9caff9c021e34之后的状态,但是服务器仍然没有改变,需要继续远程回滚
git push -f
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
remote:
remote: To create a merge request for hotfix_20210222_bugfix, visit:
remote:   http://gitlab.ukerw.com/ukerw/uker-psp/-/merge_requests/new?merge_request%5Bsource_branch%5D=hotfix_20210222_bugfix
remote:
To http://gitlab.ukerw.com/ukerw/uker-psp.git
 + 75ba6387...c085b6a0 hotfix_20210222_bugfix -> hotfix_20210222_bugfix (forced update)
0

评论区