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
相关推荐
Gazer_S2 天前
【GitLab npm Registry 非标准端口安装问题解决方案】
前端·npm·gitlab
-KamMinG2 天前
Gitlab版本升级方案-13.x到17.x
gitlab
菜鸡00014 天前
把一个项目传到 GitLab 的某个群组
大数据·elasticsearch·gitlab
AlbertS5 天前
记一次推送lfs失败不能迁移git仓库到新的gitlab的问题
git·ai·gitlab·lfs·rejected
日更嵌入式的打工仔5 天前
Windows 下 GitLab 完整使用指南
windows·gitlab
会飞的大可5 天前
Jenkins vs GitLab CI/CD:2026 企业级 CI/CD 工具深度选型评测
ci/cd·gitlab·jenkins
庭風5 天前
让 AI 从需求直接走到 MR:我开源了一个面向 GitLab 的工作流 MCP
gitlab
Sakuyu434686 天前
Git-GitLab-JenKins
git·gitlab·jenkins
Aaron_dw6 天前
基于 Jenkins + GitLab + 自动化测试的 CI/CD 自动化系统方案(IaC + 弹性构建节点)
ci/cd·gitlab·jenkins
虎头金猫6 天前
自建 GitLab 没公网?用内网穿透技术,远程开发协作超丝滑
运维·服务器·网络·开源·gitlab·开源软件·开源协议