Git add submodules to super project from existing repos Git add submodules to super project from existing repos bash bash

Git add submodules to super project from existing repos


bash-3.2$ git submodule add git@repoUrl:SubmoduleName.git existing/submodule/pathAdding existing repo at 'existing/submodule/path' to the index

when you're trying to add submodule from place where some git repo already exists this repo will be added in index.


Use Perl, just as Git does. Assuming you have the password for each:

#!/usr/bin/perl@dirs = ("admin", "editor", "etc" );foreach(@dirs){  chdir($_);  exec( "git pull origin master" );  chdir("..");}

With a little additional polish you could add better error handling and reading the password once, rather than each time.


(I know that this question very old, but maybe my reply will be useful for someone.)

Nowadays you can use git submodule foreach for such task.

And maybe git pull git pull --recurse-submodules=yes also can help you