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
相关推荐
不倒翁玩偶11 小时前
Gitlab拉取代码token换成账号密码登录
gitlab
xixingzhe213 小时前
ubuntu安装gitlab
linux·ubuntu·gitlab
切糕师学AI2 天前
GitLab 是什么?
gitlab
明月心9523 天前
git remote add 用法
gitlab
only_Klein4 天前
jenkins流水线报错:Connection reset by peer
ci/cd·kubernetes·gitlab·jenkins·ssl
梁萌5 天前
docker部署gitlab和gitlab runner
docker·eureka·gitlab
johnnyAndCode5 天前
Idea 设置GitLab时使用账密,而不是token的配置方法
gitlab·idea
天外飞雨5 天前
Gitlab使用
gitlab
BUTCHER55 天前
GitLab SSH 密钥配置
运维·ssh·gitlab
明月心9525 天前
GitLab使用
gitlab