2014-03-31 36 views
47

我在github上有一個包含部署到兩個不同域的Web應用程序的回購。該應用程序在這裏和那裏具有輕微的邏輯分支,取決於它部署到的域的行爲有所不同。將github上的git repo複製/分叉到同一組織中

現在我想將它分成兩個單獨的回購站,每個回收站對應一個域。

Github不會讓我把它分成同一個組織。尋找「git重複回購」建議我應該克隆和鏡像推它,但這似乎是爲了保持兩個同步回購,我不想這樣做。

這是什麼最好的方法呢?如果可能的話,我希望在新副本中保留舊的提交歷史記錄。

回答

64

只需創建一個新的存儲庫,並從你的工作副本推到它:

git clone [email protected]:me/myrepo-original 
cd myrepo-original 
git remote set-url origin [email protected]:me/myrepo-new 
git push origin master 

現在你有一個新的存儲庫,myrepo-new,這是相同的myrepo-original

+2

好的,這些不會跟蹤對方,對吧?意味着他們成爲兩個單獨的斷開回購?這就是我想要的。 – jemminger

+2

這兩個存儲庫都不會更新,除非您明確地「推」它,並且「新」存儲庫不會顯示與舊存儲庫的任何關係。 – larsks

+0

謝謝!看起來這是我需要的。 – jemminger

4

如果您不需要分支關係(例如,無論出於何種原因,您需要某種分離的備用回購),那麼通過Google搜索和larsks的回答將回購重複爲輪廓很好。

如果希望把它叉,請聯繫Github上支持([email protected]https://github.com/support),他們將在對您同一個組織的分支。 (他們不挑剔這個要麼,你必須只爲回購提供一個替代名稱,作爲一個帳戶內的回購協議名稱必須是唯一的。)


更新:用戶史蒂夫•賴斯報道在下面的評論中,GitHub支持部門表示支持目前不再/不再在您的賬戶中設置第二個分支。你仍然可以試着問他們,因爲支持員工可能會這樣做 - 但這也可能是一項政策變化,阻止他們這樣做。

+3

聯繫支持,他們的回覆:「目前,一個帳戶不能在同一個網絡中擁有兩個回購站。」 他們建議設置一個[鏡像回購](https://help.github.com/articles/duplicating-a-repository/)。 –

+0

很糟糕。對不起,我不知道他們改變了他們的政策:( –

2

另一種方法是將原始的repo添加爲我們當前的repo的遠程副本。

#create a new repo in the org1 organization called myrepo-new 

在你的本地終端,運行:

git clone [email protected]:org1/myrepo-new 
cd myrepo-new 
git remote -v #shows current repo link on github as origin 
git remote add name-for-remote https://github.com/org1/repo-old 
git remote -v #shows repo-old as name-for-remote 
git fetch name-for-remote 
git merge name-for-remote/branch-to-get-from-remote 
#Now fix any conflicts if present 
#If number of files/commits is very high, the desktop client may hang when you try to commit your changes after merge. Try switching to Git Shell if this happens. 
git status 
git commit -m "commit message" 
git push origin master 
-1

你不能只是複製的本地文件夾,刪除混帳東西:

rm -rf .git* 

然後做一個新的存儲庫在夾?看起來更清潔和更容易。

相關問題