如何在不更改项目根目录的情况下使用git filter-branch?

时间:2019-05-24 18:15:27

标签: git

我有git repo。我想将仓库的一个子目录拆分成自己的单独仓库。因此,我正在使用https://help.github.com/en/articles/splitting-a-subfolder-out-into-a-new-repository

但是问题是此命令将项目根目录更改为子目录。有什么办法可以使项目根目录保持不变?

我尝试了https://stackoverflow.com/a/9523876/244009选项。这样只会将整个存储库更深地移至一个目录。

1 个答案:

答案 0 :(得分:2)

git filter-branch --index-filter '
                git read-tree --empty
                git read-tree --prefix=sub/tree/ $GIT_COMMIT:sub/tree/
        ' -- yourbranch -- sub/tree

应该这样做。

相关问题