2017-03-06 51 views
0

我對git比較陌生,我需要執行以下操作。將模塊從一個回購庫移動到另一個回收庫

  1. 給出一個模塊,X,在回購A,我想移動,X,以回購乙
  2. 我需要這樣做,爲什麼同時保持某些作者的歷史。即保留「喬」和「鮑勃」的提交歷史並注意其他。

關於如何做到這一點的任何想法?

謝謝!

+1

可能重複的[git:將更改引入一個回購到另一個回購](http://stackoverflow.com/questions/3816040/git-apply-changes-introduced-by-commit-in-one- repo-to-another-repo) –

+0

您在這裏沒有定義「模塊」,這可能很重要。同時,請注意,在Git中,歷史*是*提交。這兩個是不可分割的。每個提交都是一個快照;歷史是通過隨時間播放快照而形成的。 – torek

+0

[將子目錄分離(移動)到單獨的Git存儲庫中](http://stackoverflow.com/questions/359424/detach-move-subdirectory-into-separate-git-repository) – Joe

回答

0

你可以做這樣的事情:

首先加入 '回購一個' 本地

git remote add repoa https://github.com/user/repoa.git 

然後做一個混帳推到回購

git push repoa 

Likewis EADD '回購B'本地

git remote add repob https://github.com/user/repob.git 

然後做一個混帳推回購回

git push repob 

這樣做會推高整個存儲庫的當前狀態。

現在分別克隆庫:

cd /path/where/you/want/new/repos/to/be 
git clone https://github.com/user/repoa.git repoa 
git clone https://github.com/user/repob.git repob 

(其中repoa作爲第二個參數是要克隆到目錄)

,並在每次運行git rm -r與目錄/文件要從回購中刪除,例如回購-a:

git rm -r src/repob docs/repob 

再次重複上述操作以回購-b。

然後爲每個庫運行以下命令階段,以對缺失承諾:

git add -u 

然後做一個承諾,你通常會:

git commit -m "Deleted files from repo b" 

然後推

git push origin 

重新執行最後3個命令進行repo-b。

這將創建兩個獨立的存儲庫,其中包含回購庫中所有文件的完整歷史記錄,不幸的是,我不知道保留「只有該回購庫中的文件」歷史記錄的方法。

相關問題