【发布时间】:2012-10-19 13:46:50
【问题描述】:
我有一个包含多个根目录的存储库,例如
gitroot/a
gitroot/b
gitroot/c
我想仅从 a 的内容创建一个新的 git 存储库,同时保留其历史记录。这可能吗?我已经看到了稀疏的签出,但我不确定如何使用它从子目录创建一个全新的存储库(具有相关历史记录)。
【问题讨论】:
标签: git repository sparse-checkout
我有一个包含多个根目录的存储库,例如
gitroot/a
gitroot/b
gitroot/c
我想仅从 a 的内容创建一个新的 git 存储库,同时保留其历史记录。这可能吗?我已经看到了稀疏的签出,但我不确定如何使用它从子目录创建一个全新的存储库(具有相关历史记录)。
【问题讨论】:
标签: git repository sparse-checkout
克隆现有存储库后,您可以使用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
【讨论】: