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
相关推荐
CC码码1 天前
管理你的多个 Git 密钥(多平台多账号)
git·gitlab·github
CC码码1 天前
管理你的多个 Git 密钥(单平台多账号)
git·gitlab·github
兔老大RabbitMQ1 天前
GitLab详细分析
gitlab
小道仙9714 天前
gitlab对接,gitlabRestApi,gitlab4j-api
java·git·gitlab
tswddd15 天前
项目:Gitlab HSD CI/CD总结
ci/cd·kubernetes·gitlab
许_安15 天前
docker中部署gitlab
docker·eureka·gitlab
Haoea!15 天前
持续集成 CI/CD-Jenkins持续集成GitLab项目打包docker镜像推送k8s集群并部署至rancher
ci/cd·gitlab·jenkins·rancher
xiaodaiwang15 天前
获取gitlab上项目分支版本(二)
gitlab
极小狐15 天前
GitLab CVE-2025-4278 安全漏洞解决方案
ci/cd·gitlab·devsecops·devops·gitlab升级·极狐gitlab·安全升级
weixin_4918651615 天前
git新建一个分支到gitlab项目目录中
git·gitlab