我的 Git 存储库中有一个文件夹,我想将其移出到它自己的存储库中。是否可以将该文件夹的历史记录与该文件夹一起移动?
我之前一直在执行 git rm -r --cached subfolder/
然后在子文件夹上执行 git init
。但是,历史不会导入到新存储库中。
最佳答案
引用 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 - 使用历史记录导出 Git 中的子树,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1662753/