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
相关推荐
极小狐14 小时前
CI 作业里 kubectl 连不上集群?用 Kubernetes Agent 打通部署链路的 7 个步骤
ci/cd·kubernetes·gitlab·devops·k8s部署
Zhou14113617 小时前
Git_02_GitLab协作与CI_CD
git·ci/cd·gitlab
白帽攻防录18 小时前
SRC 挖洞:GitLab GraphQL 指令绕过深度复盘,CVE-2026-19478 未授权删项目怎么打穿代码托管平台
网络·网络安全·gitlab·graphql
daemon.qiang11 天前
国内虚拟机对接 Freedesktop:Fork xserver、自建 Runner 与提交 MR 实战
linux·ubuntu·centos·gitlab·开源软件
snow@li16 天前
服务器运维:K3S 下 Jenkins ↔ GitLab 的 CI/CD 闭环 / 访问成功
运维·gitlab·jenkins
旧梦星轨18 天前
Git Flow 工作流实践
git·gitee·gitlab·github
旧梦星轨18 天前
Github Flow 与 Gitlab Flow工作流实践解读
gitlab·github
极小狐21 天前
干掉流水线里的长期密钥:用 OIDC 让 CI/CD 与云以临时凭证对接
microsoft·ci/cd·gitlab·devops·ci·cd·oidc
snow@li21 天前
服务器运维:阿里云安装软件gitlab/智能体协助安装/智能体协同运维
运维·gitlab
极小狐22 天前
CI 流水线提速实战:缓存设计与依赖代理的工程实践
缓存·ci/cd·gitlab·devops