在历史上出口Git的子树 [英] Export subtree in Git with history
问题描述
我以前一直在做一个 git rm -r - 缓存子文件夹/
,然后在子文件夹上的 git init
。但是,历史记录不会导入新的存储库。
引用一个例子,从 git-filter-branch(1)
要重写存储库,看起来好像foodir /已经是其项目根,并丢弃所有其他历史记录:
git filter-branch --subdirectory-filter foodir - --all
因此,您可以将库子目录转换为自己的存储库。请注意 - 将过滤器分支选项与修订选项分开,并且 - 重写所有分支和标记。
I have a folder in my Git repository that I'd like to move out in to its own repository. Is it possible to move the history of that folder along with the folder?
I've previously been doing just a git rm -r --cached subfolder/
and then git init
on the subfolder. However, the history is not imported in to the new repository.
Quoting an example from git-filter-branch(1)
To rewrite the repository to look as if foodir/ has been its project root, and discard all other history:
git filter-branch --subdirectory-filter foodir -- --all
Thus you can, e.g., turn a library subdirectory into a repository of its own. Note the -- that separates filter-branch options from revision options, and the --all to rewrite all branches and tags.
这篇关于在历史上出口Git的子树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!