How to split a git repository while preserving subdirectories?

后端 未结 7 1588
轻奢々
轻奢々 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:21

    Use git-filter-repo This is not part of git as of version 2.25. This requires Python3 (>=3.5) and git 2.22.0

    mkdir new_repoA
    mkdir new_repoB
    git clone originalRepo newRepoA
    git clone originalRepo newRepoB
    
    pushd
    cd new_repoA
    git filter-repo --path foo/bar --path foo/baz
    
    popd
    cd new_repoB 
    git filter-repo --path foo/qux
    

    For my repo that contained ~12000 commits git-filter-branch took more than 24 hours and git-filter-repo took less than a minute.

提交回复
热议问题