[英]Create new Main repo. Add two separate repos into Main repo but not merge them and without losing history
我正在創建一個應用程序,並一直在單獨的存儲庫中處理前端和后端。 兩者都已致力於GitHub。
現在,我要創建一個名為Main的新存儲庫,並將前端和后端存儲庫都移到Main存儲庫中。 我想將它們分開而不是合並。 我還想保留兩個倉庫的日志和提交歷史記錄。 這兩個倉庫都有分支,然后合並到master中。
我看到一些帖子,顯示了如何將回購合並到一起以保留歷史記錄,但是我不想將它們合並。
我不是在尋找子模塊,也不是孤立的分支。
在此網站上找到了答案: https : //saintgimp.org/2013/01/22/merging-two-git-repositories-into-one-repository-without-losing-file-history/
假設當前目錄是我們要在其中創建新存儲庫的位置。 創建新的存儲庫
git init
在進行合並之前,我們必須有一個初始提交,因此我們將進行一個虛擬提交。
dir > deleteme.txt
git add .
git commit -m “Initial dummy commit”
為添加一個遙控器並獲取舊的倉庫
git remote add -f old_a <OldA repo URL>
將文件從old_a / master合並到new / master
git merge old_a/master
清理我們的虛擬文件,因為我們不再需要它了
git rm .\\deleteme.txt
git commit -m “Clean up initial file”
將old_a存儲庫文件和文件夾移動到子目錄中,以免它們與以后出現的其他存儲庫沖突
mkdir old_a
dir –exclude old_a | %{git mv $_.Name old_a}
承諾搬家
git commit -m “Move old_a files into subduer”
對old_b做同樣的事情
git remote add -f old_b <OldB repo URL>
git merge old_b/master
mkdir old_b
dir –exclude old_a,old_b | %{git mv $_.Name old_b}
git commit -m “Move old_b files into subduer”
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.