8

I have a lot of remotes added in my git. Each remote is a link to a network share folder of different regions, and each remote contains the code submitted by one developer.

Everyday I need to fetch the latest code they submitted by git fetch --all.

Because of the geographical location, the speed of the network share folders are different. Some of them are very very slow. I want to fetch the data from the fastest share folder first so that I can start examining code while waiting for the fetching of other remotes.

The order of fetch by git fetch --all is not the same as the one shown by git remote -v. How is the order of fetching determined and is there a way to control the order?

palazzo train
  • 3,229
  • 1
  • 19
  • 40
  • Easiest is to put the fastest ones in a text file and `{ cat fastestones; git remote; } | while read; do git fetch $REPLY; done` -- you'll double-fetch the fast ones but so what? I don't think `git remote` has any required listing order. – jthill Oct 15 '14 at 03:38
  • Best would probably be to have one local repo per developer with just the one remote, start all those fetches in parallel, then do a fetch --all from the local ones. – jthill Nov 22 '14 at 18:35

2 Answers2

7

It's simply the order they appear in .git/config. It's just a text file, I edit it all the time.

o11c
  • 15,265
  • 4
  • 50
  • 75
6
git config remotes.default "faster slower"

Then subsequent git remote update, or git fetch --all, will always update the remotes in the specified order, i.e., first faster, then slower.

Note:

  • It's remotes, with an ending 's'.

  • Here default is the group name, other names are OK, but then need to be specified, like git remote update <group>. default happens to be the default group name if not specified.

Alternatively, in the early implementation, as git fetch --all (used also by git remote update) processes remotes in the order they appear in .git/config, thus you can change the order in .git/config to do the trick. But this is not part of the API, therefore could be broken when the implementation detail changes, as @chwarr has pointed out.

Community
  • 1
  • 1
ryenus
  • 15,711
  • 5
  • 56
  • 63
  • With git version 2.8.1.windows.1, I do not observe that `git fetch --all` uses the order in `remotes.default`. It's using the order in `.git\config`. `git remote update` does use the order in `remotes.default`. – chwarr Apr 28 '16 at 19:45