git - 使用历史记录导出 Git 中的子树

标签 git import export history

我的 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/

相关文章:

git - heroku 命令和推送给我 'CLI is deprecated. Please reinstall' 错误

python - 无法在 Windows 的 GIT bash mingw32 中激活 virtualenv

git - 推送到 GitHub 与使用 webpack 包部署到 Heroku

javascript - 使用 ES6 导入模块和 pkg

iphone - Swift ResearchKit 在没有 ConsentDocument 的情况下导出答案

git - 我如何简单地分支/复制 master 并将此分支上传到 GitHub?

python - 在 IPython 之外使用 Anaconda 模块

C++ - 如何永久导入 DLL 文件?

php - 使用php将mysql导出到xls(浏览器问题)

PHP Mysql - 导出整个数据库