How to split a git repository while preserving subdirectories?

后端 未结 7 1564
轻奢々
轻奢々 2020-11-27 16:11

What I want is similar to this question. However, I want the directory that is split into a separate repo to remain a subdirectory in that repo:

I have this:

相关标签:
7条回答
  • 2020-11-27 16:39

    A cleaner method:

    git filter-branch --index-filter '
                    git read-tree --empty
                    git reset $GIT_COMMIT path/to/dir
            ' \
            -- --all -- path/to/dir
    

    or to stick with just core commands, sub in git read-tree --prefix=path/to/dir/ $GIT_COMMIT:path/to/dir for the reset.

    Specifying path/to/dir on the rev-list args does the pruning early, with a filter this cheap it doesn't matter much but it's good to avoid the wasted effort anyway.

    0 讨论(0)
提交回复
热议问题