git 并行拉多个遥控器 [英] git pull multiple remotes in parallel
问题描述
我有一个包含数千个遥控器的存储库,我想同时从数千个遥控器中拉取数据,理想情况下我可以指定同时执行的最大数量.
I have a repo with thousands of remotes, and I'd like to pull from thousands of remotes at the same time, ideally I can specify a maximum number to do at the same time.
我无法在联机帮助页、谷歌或 git-scm 中找到与此相关的任何内容.
I wasn't able to find anything related to this in the manpages, google, or git-scm online.
完全清楚:我不想在多个存储库上运行一个命令,我有一个包含数千个遥控器的存储库.
To be perfectly clear: I do not want to run one command over multiple repos, I have one repo with thousands of remotes.
这与子模块无关,不谈子模块.子模块与 git remotes 无关.
This has nothing to do with submodules, don't talk about submodules. Submodules are unrelated to git remotes.
推荐答案
从 Git 开始 2.24它现在可能 与 [--jobs]
选项.
Starting from Git 2.24 it it now possible with [--jobs]
option.
一些例子:
获取 3 个遥控器,将并行获取 2 个遥控器:
Fetching 3 remotes, 2 remotes will be fetched in parallel:
git fetch -j2 --multiple remote1 remote2 remote3
获取所有遥控器,将并行获取 5 个遥控器:
Fetching all remotes, 5 remotes will be fetched in parallel:
git fetch -jobs=5 --all
如果您有数以千计的遥控器并且您不想下载所有遥控器,并且它们会形成一些逻辑组.而不是在命令行中指定它们(使用 --multiple
)选项您还可以在 .git/config
If you have thousands of remotes and you don't want to download all of them and they form some logical groups. Instead of specifying them in command line (with --multiple
) options You can also define remote groups like this in .git/config
[remotes]
group1 = remote1 remote2 origin
group2 = remote55 remote66
然后在 fetch 命令中使用这个组.
And then use this group in fetch command.
这个命令:git fetch --multiple -j4 group1 group2 remote10
fetches remote1 remote2 origin remote55 remote66 remote10
remotes 和 4 个 fetches 是并行完成的.
This command: git fetch --multiple -j4 group1 group2 remote10
fetches remote1 remote2 origin remote55 remote66 remote10
remotes and 4 fetches are done in parallel.
这篇关于git 并行拉多个遥控器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!