2014-10-02 139 views
3

有一臺運行Gerrit的服務器,我沒有ssh登錄權限。不過,我有一個擁有管理員權限的Gerrit帳戶。將遠程Git存儲庫遷移到新的Gerrit項目

如何創建一個新的Gerrit項目,然後將遠程Git存儲庫導入它?我希望所有信息都可以被遷移,例如分支機構和標籤。

這裏有一些更多的信息:

格里特服務器的主機名:gerrit.example.com

老混帳回購網址:SSH://[email protected]/foobar

新格里特項目名稱:foobar的

具有管理員權限格里特用戶帳號:erik

回答

4

您可以在本地桌面上運行此shell腳本。在腳本中設置Shell變量以符合您的情況。

#!/bin/sh 

# Replace these variable values according to your situation 
gerritproject=foobar 
gerritserver=gerrit.example.com 
gerritadmin=erik 
giturl=ssh://[email protected]/foobar 

set -e 
gitdir=`mktemp -d` 
ssh -p 29418 $gerritadmin@$gerritserver gerrit create-project --name $gerritproject 
cd $gitdir 
git clone --mirror $giturl tmpname 
cd tmpname 
git remote add gerritremote ssh://[email protected]$gerritserver:29418/$gerritproject 
git push gerritremote refs/*:refs/* 
+0

我回答了我自己的問題,因爲我發現很難得到這些信息。我希望答案是正確的。也許有人可以對此發表評論? – 2014-10-02 13:00:13

+0

非常多,但不要忘記推refs/tags/*。爲了獲得所有的參考文獻,我會用'--mirror'克隆並推入refs/*:refs/*。 – 2014-10-02 14:32:11

+0

@MagnusBäck我按照你的建議編輯了答案。它現在看起來好嗎? – 2014-10-06 06:54:02

相關問題