How can I move a single directory from a git repository to a new repository whilst maintaining the history?

后端 未结 3 783
执念已碎
执念已碎 2020-12-04 06:35

I have inherited a git repository containing multiple projects in separate directories. I\'d like to split the repository into new individual repositories, one for each proj

3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-04 07:12

    You can use git filter-branch to rewrite the history of a project. From the documentation:

    To rewrite the repository to look as if foodir/ had been its project root, and discard all other history:

    git filter-branch --subdirectory-filter foodir -- --all
    

    Make several copies of your repo, do that for each subdirectory you want to split out, and you should wind up with what you're looking for.

提交回复
热议问题