将大型Git存储库分割成许多较小的 [英] Split large Git repository into many smaller ones
问题描述
因此,在成功将SVN存储库转换为Git后,我现在有一个非常大的Git存储库,我想分解成多个较小的存储库并保留历史记录。 ,有人可以帮助分解可能看起来像这样的回购:
MyHugeRepo /
.git /
DIR_A /
DIR_B /
DIR_1 /
DIR_2 /
进入如下所示的两个存储库:
MyABRepo /
.git
DIR_A /
DIR_B /
My12Repo /
.git
DIR_1 /
DIR_2 /
我尝试了以上问题中的以下指示,但在尝试将多个目录放入单独的repo时并不适合(将子目录分离(移动)到单独的Git存储库中)。
这会设置MyABRepo;当然也可以做类似My12Repo。
git clone MyHugeRepo / MyABRepo.tmp /
cd MyABRepo.tmp
git filter-branch --prune-empty --index-filter'git rm --cached --ignore-unmatch DIR_1 / * DIR_2 / *'HEAD
对.git / refs / original / refs / heads / master的引用仍然存在。您可以删除它:
cd ..
git clone MyABRepo.tmp MyABRepo
code>
如果一切顺利,您可以删除MyABRepo.tmp。
如果由于某种原因你得到一个关于.git-rewrite的错误,你可以试试这个:
git clone MyHugeRepo / MyABRepo.tmp /
cd MyABRepo.tmp
git filter-branch -d /tmp/git-rewrite.tmp --prune-empty --index-filter'git rm --cached --ignore-unmatch DIR_1 / * DIR_2 / *'HEAD
cd ..
git clone MyABRepo.tmp MyABRepo
这将创建并使用/tmp/git-rewrite.tmp作为临时目录,而不是 .git-rewrite
。
当然,只要你有写权限,而且目录没有,你可以替换你想要的任何路径而不是 /tmp/git-rewrite.tmp
已经存在。
After successfully converting an SVN repository to Git, I now have a very large Git repository that I want to break down into multiple smaller repositories and maintain history.
So, can someone help with breaking up a repo that might look like this:
MyHugeRepo/
.git/
DIR_A/
DIR_B/
DIR_1/
DIR_2/
Into two repositories that look like this:
MyABRepo/
.git
DIR_A/
DIR_B/
My12Repo/
.git
DIR_1/
DIR_2/
I've tried following directions in this previous question but it doesn't really fit when trying to put multiple directories into a separate repo (Detach (move) subdirectory into separate Git repository).
This will setup MyABRepo; you can do My12Repo similarly of course.
git clone MyHugeRepo/ MyABRepo.tmp/
cd MyABRepo.tmp
git filter-branch --prune-empty --index-filter 'git rm --cached --ignore-unmatch DIR_1/* DIR_2/*' HEAD
A reference to .git/refs/original/refs/heads/master remains. You can remove that up with:
cd ..
git clone MyABRepo.tmp MyABRepo
If all went well you can then remove MyABRepo.tmp.
If for some reason you get an error regarding .git-rewrite, you can try this:
git clone MyHugeRepo/ MyABRepo.tmp/
cd MyABRepo.tmp
git filter-branch -d /tmp/git-rewrite.tmp --prune-empty --index-filter 'git rm --cached --ignore-unmatch DIR_1/* DIR_2/*' HEAD
cd ..
git clone MyABRepo.tmp MyABRepo
This will create and use /tmp/git-rewrite.tmp as a temporary directory, instead of .git-rewrite
.
Naturally, you can substitute any path you wish instead of /tmp/git-rewrite.tmp
, so long as you have write permission, and the directory does not already exist.
这篇关于将大型Git存储库分割成许多较小的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!