要求
- 保留完整的分支
- 保留提交记录
群组迁移
两种方式, 如果多就迁移,如果少,就新建。
原GitLab_群组导出
新GitLab_群组导入
Project迁移(UI方式)
原GitLab_项目导出
选择 【下载导出】
新GitLab_项目导入
Project迁移(command方式)【推荐】
核心
#从老gitlib拉取裸仓库,并在本地文件系统创建gitbook-demo.git文件夹
git clone --bare ssh://git@oldgitlab:port/group1/gitproject-demo.git
#进入代码目录
cd gitproject-demo.git
#向新git推送镜像
git push --mirror ssh://git@newgitlab:port/group1/gitproject-demo.git
-
--bare
是裸仓库的意思,区别与git clone,他不是一个工作空间,不可以在目录下进行变更操作,即使操作了也不被接受, 执行命令后会复制全部的分支、标签,并且在命令执行过程中的所有远端的变动均被忽略。
–bare
Make a bare Git repository. That is, instead of creating<directory>
and placing the administrative files in<directory>
/.git, make the<directory>
itself the $GIT_DIR. This obviously implies the --no-checkout because there is nowhere to check out the working tree. Also the branch heads at the remote are copied directly to corresponding local branch heads, without mapping them torefs/remotes/origin/. When this option is used, neither remote-tracking branches nor the related configuration variables are created.
-
--mirror
镜像代码仓库,完完整整
Instead of naming each ref to push, specifies that all refs under refs/ (which includes but is not
limited to refs/heads/, refs/remotes/, and refs/tags/) be mirrored to the remote repository.
Newly created local refs will be pushed to the remote end, locally updated refs will be force
updated on the remote end, and deleted refs will be removed from the remote end. This is the
default if the configuration option remote..mirror is set.
原Gitlab Clone bare
ysw@DESKTOP-T7NDJ0A MINGW64 /d/codeMerge
$ git clone --bare http://ip:port/xxxx/yyy.git
Cloning into bare repository 'uomSM.git'...
remote: Enumerating objects: 1438, done.
remote: Total 1438 (delta 0), reused 0 (delta 0), pack-reused 1438
Receiving objects: 100% (1438/1438), 872.14 MiB | 32.58 MiB/s, done.
Resolving deltas: 100% (420/420), done.
ysw@DESKTOP-T7NDJ0A MINGW64 /d/codeMerge
新的Gitlab创建新子群组(可选)
按需选择
推送bare版本到新Gitlab
```java
ysw@DESKTOP-T7NDJ0A MINGW64 /d/codeMerge
$ pwd
/d/codeMerge
ysw@DESKTOP-T7NDJ0A MINGW64 /d/codeMerge
$ cd uomSM.git/
- uom子群组名
- yyy自定义项目名称,我一般保持和旧的项目一致
$ git push --mirror https://新git地址/xxxx/uom/yyy.git
查看新Gitlab中的工程
OK,分支正常,提交日志正常。
设置个人访问令牌
记住该令牌
IDEA Clone Project
git clone https://xxxx/xx/xxx/xxxxx.git
输入 账号和个人访问令牌
常见问题
SSL certificate problem: self signed certificate in certificate chain
执行 git config --global http.sslverify false
remote: HTTP Basic: Access denied. The provided password or token is incorrect or your account has 2FA enabled and you must use a personal access token instead of a password. See
请按照 《设置个人访问令牌》章节设置密码,并保存该密码,使用该密码访问Gitlab文章来源:https://www.toymoban.com/news/detail-417163.html
文章来源地址https://www.toymoban.com/news/detail-417163.html
到了这里,关于Git - 记一次完整的新旧Gitlab迁移的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!