天天看点

gitblit如何迁移入gitlab合并迁移_gitlab和gitlab项目迁移

一、概述

原gitlab

操作系统:centos 6.9版本:GitLab 社区版10.5.1安装方式:yum

新gitlab

操作系统:centos 7.6版本:GitLab Community Edition13.2.0安装方式:docker

现在需要将部分老的gitlab项目,迁移到新gitlab中。

由于版本跨度比较大,不能直接将原gitlab项目备份导出,然后在新gitlab中导入。

注意:只能使用git命令行进行迁移

二、迁移

以springbootdemo项目为例:

原gitlab地址:http://gitlab.baidu.com/java/springbootdemo.git

新gitlab地址:http://gitlab.aliyun.com/java/springbootdemo.git

注意:新gitlab需要手动创建项目springbootdemo

执行以下命令:

# 拉取远程所有分支

git clone--mirror http://gitlab.baidu.com/java/springbootdemo.git

cd springbootdemo.git/git config--bool core.bare false# 切换remote_url

git remote set-url origin http://gitlab.aliyun.com/java/springbootdemo.git

# 推送所有分支

git push--mirror origin

注意:http方式下载项目,会提示输入用户名和密码。使用ssh方式就不需要了。

需要将本机的公钥写入到新gitlab中的git用户中的authorized_keys

说明:

简单使用git clone ,git fetch —all, git pull —all 都不能全部一次获取远程的所有分支,他们都只对master分支起作用,所以一次性拉取所有远程分支到本地应该使用 git clone的—mirror参数,但是这样会把它初始化为一个bare仓库,所以需要去掉这个属性