Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git add submodules to super project from existing repos

I have several (about 10-15) Git repositories in a directory:

~/plugins/admin
~/plugins/editor
~/plugins/etc

Each have their own separate repository and remote server.

The problem is that to pull all the changes from all the repositories I have to:

cd ~/plugins/admin
git pull origin master
password: ********
cd ..

cd ~/plugins/editor
git pull origin master
password: ********
cd ..

cd ~/plugins/etc
git pull origin master
password: ********
cd ..

How can I setup either Git submodules to pull all the repositories with 1 command,

OR alternatively write a script for Windows, Linux and Mac (as I use all 3 operating systems) to effectively do the same thing. Keeping in mind that the repos can be on different branches and don't necessarily have a tracking branch setup.

Same notes:

  • The password is the same for all repos
  • The remote server is the same repos (obviously in seperate repos/directories)
  • I only want to type the password in once
  • I only want to type one command to pull all repos
  • Public/private keys are not an option
  • I'm connecting to the remote via ssh
like image 768
Petah Avatar asked Dec 22 '22 23:12

Petah


1 Answers

bash-3.2$ git submodule add git@repoUrl:SubmoduleName.git existing/submodule/path
Adding 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.

like image 52
Evgen Bodunov Avatar answered Jan 06 '23 16:01

Evgen Bodunov