Convert a Git folder to a submodule retrospectively?

前端 未结 6 1112
执念已碎
执念已碎 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:47

    First change dir to folder which will be a submodule. Then:

    git init
    git remote add origin repourl
    git add .
    git commit -am'first commit in submodule'
    git push -u origin master
    cd ..
    rm -rf folder wich will be a submodule
    git commit -am'deleting folder'
    git submodule add repourl folder wich will be a submodule
    git commit -am'adding submodule'
    

提交回复
热议问题