Add a list of submodules to the git

前端 未结 2 2045
春和景丽
春和景丽 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条回答
  •  走了就别回头了
    2021-01-15 07:05

    Based on @eis suggestion, you have to create a script to make all the git add commands.

    A way to do that is to create the .gitmodules containing your needs, then parse it with a script like this one:

    iterator=1;
    subpaths=$(git config --file .gitmodules --get-regexp path | awk '{ print $2}');
    subrepos=$(git config --file .gitmodules --get-regexp url | awk '{ print $2}');
    for path in $subpaths; do
      repo=$(echo "$subrepos"| sed $iterator'q;d');
      git submodule add $repo $path;
      let iterator++;
    done
    

提交回复
热议问题