簡體   English   中英

如何在不更改歷史記錄提交哈希的情況下將一個git repo分為兩部分

[英]how to split one git repo into two without changing the history commit hash

我有一個像這樣的GIT倉庫:

  / --- [lots of work] / root --- ref_a --- .---- [ Lots of work ] orphane commit based on ref_a--- [Lots ofworks] \\ --- [lots of work] 

我想將此倉庫分成兩個倉庫

repo1:

  / --- [lots of work] / root --- ref_a --- .---- [ Lots of work ] 

repo2:

  orphane commit based on ref_a--- [Lots ofworks] \\ --- [lots of work] 

我想保持所有提交哈希完整。

可能嗎?

                 / --- [lots of work] (branch1)
                /   
 root --- ref_a --- .---- [ Lots of work ] (branch2)

      orphane commit 
            based on ref_a--- [Lots ofworks] (branch3)
                          \ --- [lots of work] (branch4)
  1. 將整個存儲庫復制到一個新文件夾中(例如,您的存儲庫位於〜/ myrepo中,而新存儲庫位於〜/ newrepo中)
  2. 在〜/ myrepo中刪除分支branch3和branch4; 在〜/ newrepo中,刪除分支branch1和branch2。
  3. 如果您有要從原始存儲庫推送到的遠程存儲庫,請不要忘記為〜/ newrepo刪除或更新遠程存儲庫。
  4. 完成。 稍后,Git GC將刪除未引用的提交,並且現有提交的哈希當然將保持不變。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM