git pull multiple remotes in parallel

后端 未结 2 1833
再見小時候
再見小時候 2020-12-11 17:55

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.

2条回答
  •  轮回少年
    2020-12-11 18:30

    Starting from Git 2.24 it it now possible with [--jobs] option.

    Some examples:

    Fetching 3 remotes, 2 remotes will be fetched in parallel:

    git fetch -j2 --multiple remote1 remote2 remote3
    

    Fetching all remotes, 5 remotes will be fetched in parallel:

    git fetch -jobs=5 --all
    

    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
    

    And then use this group in fetch command.

    This command: git fetch --multiple -j4 group1 group2 remote10 fetches remote1 remote2 origin remote55 remote66 remote10 remotes and 4 fetches are done in parallel.

提交回复
热议问题