在 Linux 上“重置 GitLab 配置”有多种含义,下面按常见场景给你对应的做法,你可以对照使用。
如果你改乱了 /etc/gitlab/gitlab.rb,想恢复到默认配置:
# 备份当前配置(很重要)
sudo cp /etc/gitlab/gitlab.rb /etc/gitlab/gitlab.rb.bak
# 重新生成默认配置
sudo gitlab-ctl revert-config
或手动恢复:
sudo rm -f /etc/gitlab/gitlab.rb
sudo gitlab-ctl reconfigure
sudo gitlab-ctl reconfigure
如果你只是忘了 root 密码:
sudo gitlab-rails console -e production
进入后执行:
user = User.where(id: 1).first
user.password = 'NewPassword123!'
user.password_confirmation = 'NewPassword123!'
user.save!
exit
⚠ 以下操作会删除所有仓库、用户、项目
# 停止服务
sudo gitlab-ctl stop
# 清除数据
sudo gitlab-ctl cleanse
# 重新配置
sudo gitlab-ctl reconfigure
# 启动
sudo gitlab-ctl start
sudo gitlab-ctl uninstall
sudo apt remove gitlab-ee # 或 gitlab-ce
sudo rm -rf /etc/gitlab /var/opt/gitlab /var/log/gitlab
然后重新安装。
# 重置 nginx
sudo gitlab-ctl remove-nginx
# 重置 redis
sudo gitlab-ctl restart redis
| 目的 | 命令 |
|---|---|
| 重置配置 | gitlab-ctl revert-config |
| 应用配置 | gitlab-ctl reconfigure |
| 重置密码 | gitlab-rails console |
| 清空数据 | gitlab-ctl cleanse |
| 重启服务 | gitlab-ctl restart |
如果你能具体说一下:
我可以给你精确命令。