[英]Moving part of Git repository to another repository preserving history
In this post I saw a method on how to clone an entire Git repository in a history preserving way.在这篇文章中,我看到了一种关于如何以保留历史记录的方式克隆整个 Git 存储库的方法。 I am now trying to split two repositories into two pieces, so that one folder in my current repository should become its own independent repository.
我现在试图将两个存储库分成两部分,以便我当前存储库中的一个文件夹成为它自己的独立存储库。 I would like to make it so that this folder was essentially cloned in a history preserving way, but such that only history concerning the files in that particular folder survives.
我想这样做是为了使该文件夹基本上以保留历史记录的方式进行克隆,但是只有与该特定文件夹中的文件有关的历史记录才能保留下来。 Is that possible?
那可能吗?
Clone the repo, then use the BFG repo cleaner to delete all the files in the other directory and all commits that are left empty because of that purge.克隆存储库,然后使用 BFG 存储库清理器删除另一个目录中的所有文件以及由于清除而留空的所有提交。
Then clone the original repo again and rinse and repeat for the other directory.然后再次克隆原始 repo 并冲洗并重复其他目录。
You can find the BFG repo cleaner here:您可以在此处找到 BFG 回购清理器:
. .
git clone --mirror git://example.com/some-big-repo.git
java -jar bfg.jar --delete-folders RemoveMe --delete-files RemoveMe
cd some-big-repo.git $ git reflog expire --expire=now --all && git gc --prune=now --aggressive
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.