gitlab代码迁移,包含历史提交记录、标签、分支

1、克隆现有的GitLab仓库(http://localhost:8888/aa/bb/cc.git)到本地,包括所有分支和标签

复制代码
git clone --bare http://localhost:8888/aa/bb/cc.git

2、在gitlab上创建一个空的仓库(http://localhost:7777/aa/bb/cc.git

复制代码
//切换到cc目录下,
cd cc.git/

//-f为强制推送
git push -f --mirror http://localhost:7777/aa/bb/cc.git

3、问题:

如果推送时报错,则应该是分支受保护了

复制代码
第一种:! [rejected]        master -> master (fetch first)
第二种:! [rejected]        master -> master (non-fast-forward)
第三种:! [remote rejected] master -> master (pre-receive hook declined)

解决,在设置->仓库->允许强制推送勾选后,再执行第二步

4、切换新仓库

复制代码
git remote set-url origin http://localhost:7777/aa/bb/cc.git
相关推荐
爱宇阳1 小时前
从零开始部署 GitLab CE 18.4.2:Docker Compose 新手教程
docker·容器·gitlab
Narutolxy14 小时前
从混合部署到高可用:在内网环境下搭建 GitLab-Jenkins-OpenResty的完整实战复盘20251014
gitlab·jenkins·openresty
字节逆旅1 天前
Git提交后追加修改操作指南
gitlab
爱宇阳1 天前
GitLab Docker Compose 迁移教程
docker·容器·gitlab
Blue啊1 天前
code Merge(qcc)
git·gitlab
友莘居士1 天前
极速迁移:GitLab项目无缝转移实战手册
gitlab·代码迁移·git命令
谢栋_1 天前
基于 GitLab CI/CD 与 Google Gemini 的 AI Code Review 自动化方案
人工智能·ci/cd·gitlab
lijunjun4 天前
当ubuntu 系统的IP地址修改之后,gitlab服务应该如何修改?
tcp/ip·ubuntu·gitlab
Qperable6 天前
gitlab-runner提示401 Unauthorized
后端·gitlab
西瓜er6 天前
Docker 一键部署指南:GitLab、Nacos、Redis、MySQL 与 MinIO 全解析
redis·docker·gitlab