Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to control the order of fetching when fetching all remotes by git fetch --all

Tags:

git

git-fetch

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?

like image 469
palazzo train Avatar asked Oct 15 '14 03:10

palazzo train


1 Answers

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.

like image 51
ryenus Avatar answered Sep 24 '22 19:09

ryenus