4

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

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

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

问题是,要从所有存储库中提取所有更改,我必须:

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 ..

如何设置任一 Git 子模块以使用 1 个命令提取所有存储库,

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

相同的注释:

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

3 回答 3

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

当您尝试从一些 git repo 已经存在的地方添加子模块时,这个 repo 将被添加到 index.html 中。

于 2010-12-01T08:04:14.277 回答
2

像 Git 一样使用 Perl。假设您有每个密码:

#!/usr/bin/perl

@dirs = ("admin", "editor", "etc" );
foreach(@dirs)
{
  chdir($_);
  exec( "git pull origin master" );
  chdir("..");
}

通过一点额外的修饰,您可以添加更好的错误处理和一次读取密码,而不是每次。

于 2010-11-22T14:33:08.250 回答
0

(我知道这个问题很老了,但也许我的回答对某人有用。)

现在你可以使用 git submodule foreach 来完成这样的任务。

也许 git pull git pull --recurse-submodules=yes 也可以帮助你

于 2017-06-21T15:38:18.153 回答