文章目录
要求
- 保留完整的分支
- 保留提交记录
群组迁移
两种方式, 如果多就迁移,如果少,就新建。
原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
版权归原作者 小小工匠 所有, 如有侵权,请联系我们删除。