Git从现有的repos向超级项目添加子模块

Pet*_*tah 4 git bash cross-platform batch-file git-submodules

我在目录中有几个(大约10-15个)Git存储库:

~/plugins/admin
~/plugins/editor
~/plugins/etc
Run Code Online (Sandbox Code Playgroud)

每个都有自己独立的存储库和远程服务器.

问题是要从我拥有的所有存储库中提取所有更改:

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 ..
Run Code Online (Sandbox Code Playgroud)

如何设置Git子模块以使用1命令拉出所有存储库,

或者为Windows,Linux和Mac编写脚本(因为我使用所有3个操作系统)来有效地执行相同的操作.请记住,存储库可以位于不同的分支上,并且不一定具有跟踪分支设置.

同样的说明:

  • 所有回购的密码都是一样的
  • 远程服务器是相同的repos(显然在单独的repos /目录中)
  • 我只想输入一次密码
  • 我只想输入一个命令来拉取所有回购
  • 公钥/私钥不是一种选择
  • 我通过ssh连接到遥控器

Evg*_*nov 9

bash-3.2$ git submodule add git@repoUrl:SubmoduleName.git existing/submodule/path
Adding existing repo at 'existing/submodule/path' to the index
Run Code Online (Sandbox Code Playgroud)

当你试图从已经存在一些git repo的地方添加子模块时,这个repo将被添加到索引中.