背景:公司业务调整,原先在海外仓库的代码转移回国内
诉求:完整的保留项目记录
操作:
步骤一: 定位到需要迁移的原项目地址
步骤二:创建新项目
步骤三:打开命令行,创建好文件路径为需要clone的项目名称
➜ dramaly-index md session_lib
➜ dramaly-index cd session_lib
➜ session_lib ls
➜ session_lib git clone --mirror 需要转的仓库地址
Cloning into bare repository 'session_lib.git'...
remote: Enumerating objects: 121, done.
remote: Counting objects: 100% (121/121), done.
remote: Compressing objects: 100% (72/72), done.
remote: Total 270 (delta 64), reused 99 (delta 49)
Receiving objects: 100% (270/270), 85.35 KiB | 455.00 KiB/s, done.
Resolving deltas: 100% (133/133), done.
➜ session_lib ls
session_lib.git
➜ session_lib cd session_lib.git
➜ session_lib.git git:(master) ls
HEAD config description hooks info objects packed-refs refs
➜ session_lib.git git:(master) git remote add destination 新创建的仓库地址
➜ session_lib.git git:(master) git push destination --mirror
推送后可能会有下边这种情况发生
➜ session_lib.git git:(master) git push destination --mirror
Enumerating objects: 270, done.
Counting objects: 100% (270/270), done.
Delta compression using up to 8 threads
Compressing objects: 100% (121/121), done.
Writing objects: 100% (270/270), 85.34 KiB | 85.34 MiB/s, done.
Total 270 (delta 133), reused 270 (delta 133), pack-reused 0
remote: Resolving deltas: 100% (133/133), done.
To https://git.didi-inc.com:8021/dramaly-service/session_lib.git
* [new branch] add_interface -> add_interface
* [new branch] develop -> develop
* [new branch] feature_white_module_list -> feature_white_module_list
* [new branch] master -> master
* [new reference] refs/merge-requests/1/head -> refs/merge-requests/1/head
* [new reference] refs/merge-requests/10/head -> refs/merge-requests/10/head
* [new reference] refs/merge-requests/11/head -> refs/merge-requests/11/head
* [new reference] refs/merge-requests/12/head -> refs/merge-requests/12/head
* [new reference] refs/merge-requests/13/head -> refs/merge-requests/13/head
* [new reference] refs/merge-requests/14/head -> refs/merge-requests/14/head
* [new reference] refs/merge-requests/15/head -> refs/merge-requests/15/head
* [new reference] refs/merge-requests/16/head -> refs/merge-requests/16/head
* [new reference] refs/merge-requests/17/head -> refs/merge-requests/17/head
* [new reference] refs/merge-requests/18/head -> refs/merge-requests/18/head
* [new reference] refs/merge-requests/19/head -> refs/merge-requests/19/head
* [new reference] refs/merge-requests/2/head -> refs/merge-requests/2/head
* [new reference] refs/merge-requests/20/head -> refs/merge-requests/20/head
* [new reference] refs/merge-requests/21/head -> refs/merge-requests/21/head
* [new reference] refs/merge-requests/22/head -> refs/merge-requests/22/head
* [new reference] refs/merge-requests/23/head -> refs/merge-requests/23/head
* [new reference] refs/merge-requests/24/head -> refs/merge-requests/24/head
* [new reference] refs/merge-requests/25/head -> refs/merge-requests/25/head
* [new reference] refs/merge-requests/26/head -> refs/merge-requests/26/head
* [new reference] refs/merge-requests/27/head -> refs/merge-requests/27/head
* [new reference] refs/merge-requests/28/head -> refs/merge-requests/28/head
* [new reference] refs/merge-requests/29/head -> refs/merge-requests/29/head
* [new reference] refs/merge-requests/3/head -> refs/merge-requests/3/head
* [new reference] refs/merge-requests/30/head -> refs/merge-requests/30/head
* [new reference] refs/merge-requests/31/head -> refs/merge-requests/31/head
* [new reference] refs/merge-requests/32/head -> refs/merge-requests/32/head
* [new reference] refs/merge-requests/33/head -> refs/merge-requests/33/head
* [new reference] refs/merge-requests/34/head -> refs/merge-requests/34/head
* [new reference] refs/merge-requests/35/head -> refs/merge-requests/35/head
* [new reference] refs/merge-requests/4/head -> refs/merge-requests/4/head
* [new reference] refs/merge-requests/5/head -> refs/merge-requests/5/head
* [new reference] refs/merge-requests/6/head -> refs/merge-requests/6/head
* [new reference] refs/merge-requests/7/head -> refs/merge-requests/7/head
* [new reference] refs/merge-requests/8/head -> refs/merge-requests/8/head
* [new reference] refs/merge-requests/9/head -> refs/merge-requests/9/head
* [new tag] v1.0.0 -> v1.0.0
* [new tag] v1.0.1 -> v1.0.1
* [new tag] v1.0.2 -> v1.0.2
* [new tag] v1.0.3 -> v1.0.3
* [new tag] v1.0.4 -> v1.0.4
! [remote rejected] refs/keep-around/041f49a3840ef60c69b5802afa39df8204237b5b -> refs/keep-around/041f49a3840ef60c69b5802afa39df8204237b5b (deny updating a hidden ref)
! [remote rejected] refs/keep-around/056a060d38c36e13eff8e9d663fcc091d77812e3 -> refs/keep-around/056a060d38c36e13eff8e9d663fcc091d77812e3 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/0a1c0ba7778ba10fe3a29ba4d3f047df34e59863 -> refs/keep-around/0a1c0ba7778ba10fe3a29ba4d3f047df34e59863 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/0b22d70c5aa66e1043545fec7e2a644b2f414ec2 -> refs/keep-around/0b22d70c5aa66e1043545fec7e2a644b2f414ec2 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/0f398c895d0ed06c8fb6378a4b972fb7af8c3c18 -> refs/keep-around/0f398c895d0ed06c8fb6378a4b972fb7af8c3c18 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/13e51c044eefd20d41a24c7c770611b5b6fd96e3 -> refs/keep-around/13e51c044eefd20d41a24c7c770611b5b6fd96e3 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/193de930433660e09cbdc549e522687e04556961 -> refs/keep-around/193de930433660e09cbdc549e522687e04556961 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/1a8ea198f3a5e9d087a8edb91c1f210de9904a05 -> refs/keep-around/1a8ea198f3a5e9d087a8edb91c1f210de9904a05 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/1eb3aa2e7e5bd5143ca5b1acb915006cb6261098 -> refs/keep-around/1eb3aa2e7e5bd5143ca5b1acb915006cb6261098 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/20611f497498e2573243408ec6d68035495eecc6 -> refs/keep-around/20611f497498e2573243408ec6d68035495eecc6 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/23b9eb31148361b071b695d911bb828d6788d94a -> refs/keep-around/23b9eb31148361b071b695d911bb828d6788d94a (deny updating a hidden ref)
! [remote rejected] refs/keep-around/28112e08d221cec46069469c80308e4b5445b8ec -> refs/keep-around/28112e08d221cec46069469c80308e4b5445b8ec (deny updating a hidden ref)
! [remote rejected] refs/keep-around/2a68173e7bb83792e4018b5b134d7e8263145efb -> refs/keep-around/2a68173e7bb83792e4018b5b134d7e8263145efb (deny updating a hidden ref)
! [remote rejected] refs/keep-around/3104dec79f427d51ab83f65159cef9827dfeb20d -> refs/keep-around/3104dec79f427d51ab83f65159cef9827dfeb20d (deny updating a hidden ref)
! [remote rejected] refs/keep-around/32b57c60d9a9b779a54276a2b4f0e84c9fba3319 -> refs/keep-around/32b57c60d9a9b779a54276a2b4f0e84c9fba3319 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/367eda90d77207ca55bc6d4dae9cb97aae1be552 -> refs/keep-around/367eda90d77207ca55bc6d4dae9cb97aae1be552 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/39ea1303a222f507a6b7954091e1a56ffd3544b2 -> refs/keep-around/39ea1303a222f507a6b7954091e1a56ffd3544b2 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/3a075f279e85d0c3951a906fb8df261b4bbda584 -> refs/keep-around/3a075f279e85d0c3951a906fb8df261b4bbda584 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/3b3273b590c416327f7dc82fa0cbcdc073e578d4 -> refs/keep-around/3b3273b590c416327f7dc82fa0cbcdc073e578d4 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/425d9053d90976ee6d4a0023831638ec4ab40287 -> refs/keep-around/425d9053d90976ee6d4a0023831638ec4ab40287 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/4d6374daf49d48be8a87bbf7ea27a82bec93eaee -> refs/keep-around/4d6374daf49d48be8a87bbf7ea27a82bec93eaee (deny updating a hidden ref)
! [remote rejected] refs/keep-around/4f0f1e9a9911659f1e798a5399cb91cf99d22ba5 -> refs/keep-around/4f0f1e9a9911659f1e798a5399cb91cf99d22ba5 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/508b0d93dfd2e463b1bb80db7d9bc911484622ec -> refs/keep-around/508b0d93dfd2e463b1bb80db7d9bc911484622ec (deny updating a hidden ref)
! [remote rejected] refs/keep-around/536b720b70eb5c6f37ef5f37f038e5477eb3a9ce -> refs/keep-around/536b720b70eb5c6f37ef5f37f038e5477eb3a9ce (deny updating a hidden ref)
! [remote rejected] refs/keep-around/567ae1046dc458808606161d1b0f4a97ff2dd13a -> refs/keep-around/567ae1046dc458808606161d1b0f4a97ff2dd13a (deny updating a hidden ref)
! [remote rejected] refs/keep-around/56d4f927bda0eeb19db63b6479e1aec5f9b306bd -> refs/keep-around/56d4f927bda0eeb19db63b6479e1aec5f9b306bd (deny updating a hidden ref)
! [remote rejected] refs/keep-around/582e7befcfb31bb448567878ff91cf338d852249 -> refs/keep-around/582e7befcfb31bb448567878ff91cf338d852249 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/5bcaeda067235dc77beee1a730bb58274ec4f2ca -> refs/keep-around/5bcaeda067235dc77beee1a730bb58274ec4f2ca (deny updating a hidden ref)
! [remote rejected] refs/keep-around/5eea3450627f59cb79bb022e943a047fa0286ca2 -> refs/keep-around/5eea3450627f59cb79bb022e943a047fa0286ca2 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/662c99affa5f659a9b890b9f7e7a34ee67360698 -> refs/keep-around/662c99affa5f659a9b890b9f7e7a34ee67360698 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/6722bdc727a9ade979036f227fcedb4ace2e6809 -> refs/keep-around/6722bdc727a9ade979036f227fcedb4ace2e6809 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/6aaea72859e9c06fa1b977c7c813298ae249b507 -> refs/keep-around/6aaea72859e9c06fa1b977c7c813298ae249b507 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/74236a35fbd7a3a0938b868b029d0e0350cf20e0 -> refs/keep-around/74236a35fbd7a3a0938b868b029d0e0350cf20e0 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/78e41414794553587a693ce41732b60ec7bd101a -> refs/keep-around/78e41414794553587a693ce41732b60ec7bd101a (deny updating a hidden ref)
! [remote rejected] refs/keep-around/811493b6fdae2331b0a94c7a3fe65a3000f0e92b -> refs/keep-around/811493b6fdae2331b0a94c7a3fe65a3000f0e92b (deny updating a hidden ref)
! [remote rejected] refs/keep-around/8c3d3377714fdea5468e7648c25c625da517e501 -> refs/keep-around/8c3d3377714fdea5468e7648c25c625da517e501 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/8d3c1963907df786b2e9556719cdf801e25d30dd -> refs/keep-around/8d3c1963907df786b2e9556719cdf801e25d30dd (deny updating a hidden ref)
! [remote rejected] refs/keep-around/8d71603be6dcc20892aea7dde55e2ca37437e1ec -> refs/keep-around/8d71603be6dcc20892aea7dde55e2ca37437e1ec (deny updating a hidden ref)
! [remote rejected] refs/keep-around/914f1ff0b0c68e5ccc43bfb16db243c759595a2e -> refs/keep-around/914f1ff0b0c68e5ccc43bfb16db243c759595a2e (deny updating a hidden ref)
! [remote rejected] refs/keep-around/93b4bc0091ef258c9b33599aea53006f366bf30b -> refs/keep-around/93b4bc0091ef258c9b33599aea53006f366bf30b (deny updating a hidden ref)
! [remote rejected] refs/keep-around/9498146addd947d1e608f0b9faf3542ec53b91b6 -> refs/keep-around/9498146addd947d1e608f0b9faf3542ec53b91b6 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/970ae217af3abd8d36cdf4bfb3071a7abbb7ac92 -> refs/keep-around/970ae217af3abd8d36cdf4bfb3071a7abbb7ac92 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/9c9a233f6e8d84cfabfdf70aade2023bb9800a11 -> refs/keep-around/9c9a233f6e8d84cfabfdf70aade2023bb9800a11 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/9f1e8e26d1cd71db84263e862614ea2f5e9edc22 -> refs/keep-around/9f1e8e26d1cd71db84263e862614ea2f5e9edc22 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/9f2381b9af9372c00fb6c93974da0d5fb8ebb624 -> refs/keep-around/9f2381b9af9372c00fb6c93974da0d5fb8ebb624 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/9f896a51a232fdfb093ae4969b75f11e84feceb9 -> refs/keep-around/9f896a51a232fdfb093ae4969b75f11e84feceb9 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/9fa29a3034709ec648b65fc948babf5e790ecc91 -> refs/keep-around/9fa29a3034709ec648b65fc948babf5e790ecc91 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/a7e126fea8ac8df616ff358a920d120f8b58d2ba -> refs/keep-around/a7e126fea8ac8df616ff358a920d120f8b58d2ba (deny updating a hidden ref)
! [remote rejected] refs/keep-around/aac4449bb0a4d725ef2b5d9cad474ec60b5c5a07 -> refs/keep-around/aac4449bb0a4d725ef2b5d9cad474ec60b5c5a07 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/ad52addc4c5aaf0a2cdfb635163f9be459cc50de -> refs/keep-around/ad52addc4c5aaf0a2cdfb635163f9be459cc50de (deny updating a hidden ref)
! [remote rejected] refs/keep-around/b5b7e3a55c30ce05147f70327a2a6d9f3f7991db -> refs/keep-around/b5b7e3a55c30ce05147f70327a2a6d9f3f7991db (deny updating a hidden ref)
! [remote rejected] refs/keep-around/bba593e5e3c21bc47e377c929a2be29dc69be561 -> refs/keep-around/bba593e5e3c21bc47e377c929a2be29dc69be561 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/be7060e325ad95964cf0bcdd2ec00fbae6eb744a -> refs/keep-around/be7060e325ad95964cf0bcdd2ec00fbae6eb744a (deny updating a hidden ref)
! [remote rejected] refs/keep-around/c2ecc8a2867245c3ddce1bf56688eb209a641b0c -> refs/keep-around/c2ecc8a2867245c3ddce1bf56688eb209a641b0c (deny updating a hidden ref)
! [remote rejected] refs/keep-around/ca6b8628b5afde052fe8c05306dc24312507cfd1 -> refs/keep-around/ca6b8628b5afde052fe8c05306dc24312507cfd1 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/ccf49dc5df928ff11e3880a1904647e2fd463a1f -> refs/keep-around/ccf49dc5df928ff11e3880a1904647e2fd463a1f (deny updating a hidden ref)
! [remote rejected] refs/keep-around/d704a5eb01adcad70703badba4e90d4a7ac5fc7d -> refs/keep-around/d704a5eb01adcad70703badba4e90d4a7ac5fc7d (deny updating a hidden ref)
! [remote rejected] refs/keep-around/d788d4d14f94860cb0c22c7716e9f67a237c1d3e -> refs/keep-around/d788d4d14f94860cb0c22c7716e9f67a237c1d3e (deny updating a hidden ref)
! [remote rejected] refs/keep-around/da94e135b048bbd2691429a5502823e1305fb068 -> refs/keep-around/da94e135b048bbd2691429a5502823e1305fb068 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/db06c6846108682303e41237c8410debf5c046e6 -> refs/keep-around/db06c6846108682303e41237c8410debf5c046e6 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/e07a5c369fa3ae47460ead06cc25a317308dd25e -> refs/keep-around/e07a5c369fa3ae47460ead06cc25a317308dd25e (deny updating a hidden ref)
! [remote rejected] refs/keep-around/e20a2e69aaa400073b5c9337fc20d3bd807f2180 -> refs/keep-around/e20a2e69aaa400073b5c9337fc20d3bd807f2180 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/e3c2cdd97753559daf33077f4cd68b0e7b6a81fb -> refs/keep-around/e3c2cdd97753559daf33077f4cd68b0e7b6a81fb (deny updating a hidden ref)
! [remote rejected] refs/keep-around/e93ad43217271910c21ab17506fb6114f6590149 -> refs/keep-around/e93ad43217271910c21ab17506fb6114f6590149 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/eac96d30e74cc57490c13bed8a486c321d25575d -> refs/keep-around/eac96d30e74cc57490c13bed8a486c321d25575d (deny updating a hidden ref)
! [remote rejected] refs/keep-around/eee415278c6e8056dbcda6042812e46f6ef2464e -> refs/keep-around/eee415278c6e8056dbcda6042812e46f6ef2464e (deny updating a hidden ref)
! [remote rejected] refs/keep-around/f44321a6ca18a6da0d47d47d5d0e1c857d12aaea -> refs/keep-around/f44321a6ca18a6da0d47d47d5d0e1c857d12aaea (deny updating a hidden ref)
! [remote rejected] refs/keep-around/f652fc4e7c8f492ce1f852bcd31739c42ea11925 -> refs/keep-around/f652fc4e7c8f492ce1f852bcd31739c42ea11925 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/fb8625be9e1ccc7ddab1ae839bf0f4e5bbaf920d -> refs/keep-around/fb8625be9e1ccc7ddab1ae839bf0f4e5bbaf920d (deny updating a hidden ref)
! [remote rejected] refs/keep-around/fc5b903264dcb7f7ba31ab7337083d0097bffc93 -> refs/keep-around/fc5b903264dcb7f7ba31ab7337083d0097bffc93 (deny updating a hidden ref)
! [remote rejected] refs/keep-around/fce696b22934c3af04ca3dfea9eefc01de20a537 -> refs/keep-around/fce696b22934c3af04ca3dfea9eefc01de20a537 (deny updating a hidden ref)
error: failed to push some refs to 'https://git.didi-inc.com:8021/dramaly-service/session_lib.git'
➜ session_lib.git git:(master)
PS: 那些被远程拒绝的是git的隐藏refs,gitLab用来保存某些临时状态或历史记录的内部引用。当批量推到新的仓库这些东西就不需要了。是gitlab的默认操作。
重要:此时刷新仓库后注意观察文件大小,以及分支个数是否正确。分支可能不相等,因为原先追踪有失败的。大小也会发生变化(皆为正常现象)
步骤三:刷新新仓库前 VS 刷新仓库后
原仓库快照:
新仓库快照
到此:大功告成