Add a list of submodules to the git

前端 未结 2 2062
春和景丽
春和景丽 2021-01-15 06:02

I have cloned a project and customized it. the project is using some extra projects as submodules. I have setup mine git repository and push the main project there. but I d

2条回答
  •  萌比男神i
    2021-01-15 06:55

    I don't think there is such a way with git. However, you could just do a shell script that iterates your list and calls git submodule add on each of them, one by one.


    Why just copying them to .gitmodules or to .git/index won't do the trick:

    The "git submodule add" command does a couple of things:

    • It clones the submodule under the current directory and by default checks out the master branch.
    • It adds the submodule's clone path to the ".gitmodules" file and adds this file to the index, ready to be committed.
    • It adds the submodule's current commit ID to the index, ready to be committed.

    (source)

    So you would be missing the last step, and git submodule init/update expect the commit id to be already in place. That is why you need git submodule add.

提交回复
热议问题