2012-10-19 76 views
1

我有一個版本庫,其中包含幾個根目錄,例如:git將舊版本庫的一部分移動到一個新的版本庫

gitroot/a 
gitroot/b 
gitroot/c 

而且我想僅從的內容創建一個新的git倉庫,同時保留它的歷史。這可能嗎?我已經看到了稀疏的結帳,但我不知道如何使用它從子目錄創建一個全新的存儲庫(具有相關歷史記錄)。

回答

2

克隆現有的資源庫後,您可以使用filter-branch

git filter-branch --subdirectory-filter a -- --all 

之後;

git clean -d -f // Remove untracked files from the working tree 
git gc --aggressive // Cleanup unnecessary files and optimize the local repository 
git prune // Prune all unreachable objects from the object database 
+0

絕對精彩,完美的作品。謝謝 – user1207217

相關問題