2013-12-03 30 views
77

我有一個帳戶,我創建的存儲庫「ffki-startseite」將現有的git項目導入到GitLab中?

現在我要到倉庫git://freifunk.in-kiel.de/ffki-startseite.git克隆與所有的提交和分支該儲存庫的Gitlab安裝的,這樣我就可以開始工作的我自己的範圍。

我該如何導入它?

+0

gitlab的新功能,然後創建項目進入項目頁面。在這裏你會看到基本的說明。 –

回答

74

遠程添加新gitlab到現有的存儲庫,並推動:

git remote add gitlab url-to-gitlab-repo 
git push gitlab master 
+0

我不得不用力推它,因爲我已經在gitLab中弄亂了:'git push gitlab master -f'。現在,我有全新的GitLab中的所有提交回購;)謝謝 – rubo77

+15

你不需要做一個鏡像?如果你有其他分支而不是主人? – slhck

+7

是的,按照OP的建議,你會**失去所有分支(master除外)和標籤** – raveren

10

rake gitlab:import:repos可能是大衆進口更合適的方法:

  • 複製repos_path/home/git/repositories/group/repo.git)下的純倉庫。目錄名稱必須以.git結尾,並位於組或用戶名稱空間下。
  • 運行bundle exec rake gitlab:import:repos

業主將第一管理,並有一批會得到如果不是已經存在的創建。

參見:How to import an existing bare git repository into Gitlab?

+0

對於那些可能會感到困惑的人來說,裸倉庫通常是位於集中位置(例如github)的倉庫,倉庫根目錄下不包含.git文件夾。 如果您有權訪問存儲裸倉庫的服務器,這只是一個方便的選項。否則@Raveren的答案是最好的選擇。 – TinkerTenorSoftwareGuy

102

我能夠與所有提交,分支和標籤沿着完全導出我的項目通過以下命令我的計算機上本地運行gitlab:

爲了說明我例如,我將使用https://github.com/raveren/kint作爲我想要導入到gitlab中的源代碼庫。我創建了一個名爲gitlab Kint(下命名空間raveren)的空項目事前,它告訴我,新建項目的HTTP git的URL有http://gitlab.example.com/raveren/kint.git

的命令是與操作系統無關。

目錄:

git clone --mirror https://github.com/raveren/kint 
cd kint.git 
git remote add gitlab http://gitlab.example.com/raveren/kint.git 
git push gitlab --mirror 

現在,如果你有,你要保持與新的遠程使用,只需運行下面的命令*有一個本地克隆庫:

git remote remove origin 
git remote add origin http://gitlab.example.com/raveren/kint.git 
git fetch --all 

*這裏假設您沒有將您的遠程主機從origin重命名,否則請更改前兩行以反映它。

3
git clone --mirror [email protected]:username/repo-name.git 

git remote add gitlab ssh://[email protected]/username/repo.git 

git push -f --tags gitlab refs/heads/*:refs/heads/* 

這是更好地做到這一點通過ssh,https的可能將無法正常工作

3

這是一個基本招一式回購到新的位置。我一直都在使用這個序列。與- 只有沒有源文件將被看到。

打開Git Bash。
創建存儲庫的裸露克隆。

git clone --bare https://github.com/exampleuser/old-repository.git 

鏡像推送到新的存儲庫。

cd old-repository.git 

git push --mirror https://github.com/exampleuser/new-repository.git 

刪除您在步驟中創建的臨時本地資源庫1

cd .. 
rm -rf old-repository.git 
1

爲了保持所有的標籤和分支

只需簡單地在existing Git repository

cd existing_repo 
git remote add gitlab [email protected]:hutber/kindred.com.git 
git push -u gitlab --all 
git push -u gitlab --tags 
運行此命令