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
相关推荐
不念霉运17 小时前
2025 Gitee vs. GitLab:全面对比与选择指南
gitee·gitlab
水瓶_bxt17 小时前
创建 GitLab Runner 使用CICD自动化部署容器
eureka·自动化·gitlab
黑心的奥利奥3 天前
Docker配置Gitlab-runner实现自动化容器化部署前端项目
docker·自动化·gitlab
wuzuyu3653 天前
在腾讯云上安装gitlab
云计算·gitlab·腾讯云
xiaodaiwang3 天前
OpenEuler 22.03 系统上安装配置gitlab runner
gitlab
TimberWill3 天前
gitlab私服搭建
gitlab
中东大鹅3 天前
访问 gitlab 跳转 0.0.0.0
gitlab
guygg884 天前
配置本地git到gitlab并推送
git·gitlab
大A崛起4 天前
Gitlab-CI实现组件自动推送
ci/cd·gitlab·github
越来越无动于衷5 天前
GitLab 社区版 10.8.4 安装、汉化与使用教程
gitlab