git倉庫完整遷移

weixin_34127717發表於2018-07-02

前言
在專案變動時,經常會遷移git倉庫,這個時候完整的遷移git倉庫,有利於後期的維護,因為git倉庫裡面包含了專案的各個分支,提交歷史等

git倉庫完整遷移

源庫:gitlab@github.news.com/groups:test.com.git
目標庫: gitlab@github.xx.com/newgroups:newtest.com.git

1.克隆git的版本庫

git clone --bare gitlab@github.news.com/groups:test.com.git
Initialized empty Git repository in /home/test/test.com.git/
remote: Counting objects: 8569, done.
remote: Compressing objects: 100% (2606/2606), done.
remote: Total 8569 (delta 6374), reused 7917 (delta 5793)
Receiving objects: 100% (8569/8569), 83.36 MiB | 9.57 MiB/s, done.
Resolving deltas: 100% (6374/6374), done.

2.去目標倉庫設定,將Protect保護去掉,如下圖紅框部分

gitlab->group->newtest.com->點選設定->Protected branches

clipboard.png

3.以映象推送的方式上傳程式碼到gitlab伺服器上

git push --mirror gitlab@github.xx.com:newgroups/newtest.com.git
Counting objects: 8569, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2025/2025), done.
Writing objects: 100% (8569/8569), 83.36 MiB | 28.47 MiB/s, done.
Total 8569 (delta 6374), reused 8569 (delta 6374)
To gitlab@github.meizu.com:private/ba.meizu.com.git
 + 5269023...ec9c11e master -> master (forced update)
 * [new branch]      feature/eco -> feature/eco
 * [new branch]      origin/feature/eco -> origin/feature/eco

注意事項

1.git倉庫遷移前,目標倉庫需要先建立,且為空
2.需要事先將倉庫的protect許可權去掉,否則在git push的時候會報錯

相關文章