Convert a Git folder to a submodule retrospectively?

前端 未结 6 1129
执念已碎
执念已碎 2020-11-28 18:49

Quite often it is the case that you\'re writing a project of some kind, and after a while it becomes clear that some component of the project is actually useful as a standal

6条回答
  •  情话喂你
    2020-11-28 19:27

    To isolate a subdirectory into its own repository, use filter-branch on a clone of the original repository:

    git clone  
    cd 
    git filter-branch --subdirectory-filter 'path/to/your/submodule' --prune-empty -- --all
    

    It's then nothing more than deleting your original directory and adding the submodule to your parent project.

提交回复
热议问题