要求
- 保留完整的分支
- 保留提交記錄
群組遷移
兩種方式, 如果多就遷移,如果少,就新建。
原GitLab_群組導(dǎo)出
新GitLab_群組導(dǎo)入
Project遷移(UI方式)
原GitLab_項(xiàng)目導(dǎo)出
選擇 【下載導(dǎo)出】
新GitLab_項(xiàng)目導(dǎo)入
Project遷移(command方式)【推薦】
核心
#從老gitlib拉取裸倉(cāng)庫(kù),并在本地文件系統(tǒng)創(chuàng)建gitbook-demo.git文件夾
git clone --bare ssh://git@oldgitlab:port/group1/gitproject-demo.git
#進(jìn)入代碼目錄
cd gitproject-demo.git
#向新git推送鏡像
git push --mirror ssh://git@newgitlab:port/group1/gitproject-demo.git
-
--bare
是裸倉(cāng)庫(kù)的意思,區(qū)別與git clone,他不是一個(gè)工作空間,不可以在目錄下進(jìn)行變更操作,即使操作了也不被接受, 執(zhí)行命令后會(huì)復(fù)制全部的分支、標(biāo)簽,并且在命令執(zhí)行過(guò)程中的所有遠(yuǎn)端的變動(dòng)均被忽略。
–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
鏡像代碼倉(cāng)庫(kù),完完整整
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創(chuàng)建新子群組(可選)
按需選擇
推送bare版本到新Gitlab
```java
ysw@DESKTOP-T7NDJ0A MINGW64 /d/codeMerge
$ pwd
/d/codeMerge
ysw@DESKTOP-T7NDJ0A MINGW64 /d/codeMerge
$ cd uomSM.git/
- uom子群組名
- yyy自定義項(xiàng)目名稱,我一般保持和舊的項(xiàng)目一致
$ git push --mirror https://新git地址/xxxx/uom/yyy.git
查看新Gitlab中的工程
OK,分支正常,提交日志正常。
設(shè)置個(gè)人訪問(wèn)令牌
記住該令牌
IDEA Clone Project
git clone https://xxxx/xx/xxx/xxxxx.git
輸入 賬號(hào)和個(gè)人訪問(wèn)令牌
常見(jiàn)問(wèn)題
SSL certificate problem: self signed certificate in certificate chain
執(zhí)行 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
請(qǐng)按照 《設(shè)置個(gè)人訪問(wèn)令牌》章節(jié)設(shè)置密碼,并保存該密碼,使用該密碼訪問(wèn)Gitlab文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-417163.html
文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-417163.html
到了這里,關(guān)于Git - 記一次完整的新舊Gitlab遷移的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!