【问题标题】:After using git filter-branch --subdirectory-filter how do I still use old repo and reclaim git space?使用 git filter-branch --subdirectory-filter 后,我如何仍然使用旧的 repo 并回收 git 空间?
【发布时间】:2018-03-14 04:04:43
【问题描述】:

我使用git filter-branch 将一个子文件夹拆分到一个新的存储库中,参考https://help.github.com/articles/splitting-a-subfolder-out-into-a-new-repository/https://stackoverflow.com/a/45983384/301513

我的问题是,根据文章中的步骤,我需要创建一个新的 repo 和 git pull the-subdirectory-filter-result 到新的 repo 中。但是有没有可能我仍然可以使用旧的 repo 并回收 git 空间,即让旧的 .git 只有那个子目录相关的元数据?如果可以的话,我不需要创建一个新的 repo,毕竟旧的 repo 现在没有太多用处了。

我在https://stackoverflow.com/a/359759/301513 尝试了 Paul 的回答中的第 5 步,但没有奏效。并且git gc 不会为那些不相关的提交回收 git 历史记录。

【问题讨论】:

    标签: git git-subtree git-filter-branch git-rewrite-history


    【解决方案1】:

    您可以 rm 您不想要的历史记录和文件夹,然后将文件移动到根目录。这里Remove folder and its contents from git/GitHub's history 是 rm 文件夹和文件的几个选项。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-29
      • 2020-07-22
      • 1970-01-01
      • 1970-01-01
      • 2012-04-29
      • 1970-01-01
      • 2011-12-01
      • 2020-09-19
      相关资源
      最近更新 更多