在 CentOS 上回滚 GitLab,通常有三种常见场景,下面分别说明:
如果你是因为 升级 GitLab 后出问题,需要回滚到旧版本。
rpm -qa | grep gitlab
gitlab-ctl stop
以 CentOS 7 为例(替换为你需要回滚的版本):
yum install -y https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-15.11.0-ce.0.el7.x86_64.rpm/download.rpm
或手动下载:
wget https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-15.11.0-ce.0.el7.x86_64.rpm
rpm -Uvh --oldpackage gitlab-ce-15.11.0-ce.0.el7.x86_64.rpm
gitlab-ctl reconfigure
gitlab-ctl start
✅ 注意
如果是 GitLab 上的代码提交错误:
git log
git reset --hard <commit_id>
git push -f origin <branch>
git revert <commit_id>
git push origin <branch>
如果改坏了 GitLab 配置:
gitlab-ctl stop
cp /etc/gitlab/gitlab.rb /etc/gitlab/gitlab.rb.bak
# 恢复旧配置
gitlab-ctl reconfigure
gitlab-ctl start
如果你有 备份:
gitlab-rake gitlab:backup:restore BACKUP=时间戳
✅ 升级前:
gitlab-rake gitlab:backup:create
✅ 使用版本锁定:
yum versionlock gitlab-ce
如果你能说明是 哪种回滚(版本 / 代码 / 配置 / 数据),我可以给你更精确的命令。