Re: git fetch with multiple remotes failing?

From: Linus Torvalds <>
Date: 2006-11-01 03:32:06
On Tue, 31 Oct 2006, Michael S. Tsirkin wrote:
> $ cat .git/remotes/origin
> URL: git://
> Pull: +refs/heads/master:refs/heads/linus_master
> $ cat .git/remotes/jejb-scsi-misc-2.6
> URL: git://
> Pull: +refs/heads/master:refs/heads/jejb-scsi-misc-2.6
> $ git fetch -f origin jejb-scsi-misc-2.6
> error: no such remote ref refs/heads/jejb-scsi-misc-2.6
> Fetch failure:
> git://
> Looks I must give remotes one by one?

Yes. A single "fetch" will only ever connect to a single repository. If 
you want to fetch from multiple repositories, you have to do multiple 
connections, and thus multiple "fetch"es.

The protocol doesn't even really allow for connecting to two different 
repositories with one connection.

There's also a purely syntactic issue: when you say

	git fetch -f origin jejb-scsi-misc-2.6

then the "origin" is considered to specify the repository (and any 
"default branches") and any subsequent arguments are considered to 
override the _branch_ information in that repository. So the above command 
literally means "fetch branch 'jejb-scsi-misc-2.6' from the repository 
described by 'origin'".

Btw, this _syntactic_ issue is separate from the issue of actually 
initiating multiple connections. For example, "git push" actually 
understands that you can push multiple different repositories at once, but 
even then you can't specify it on the command line directly, for the exact 
same reason as the above "git fetch" thing: the first argument is 
considered the "repository" specifier, and any subsequent arguments are 
specifiers for which branches/tags to push.

So for "git push" (where it makes sense to push the same branches multiple 
times), you can actually do what I do:

 - .git/config contains:

	[remote "all"]
		url =
		url =

 - and not "git push all master" will push the "master" branch to _both_ 
   of those remote repositories.

However, even that doesn't really make sense for "git fetch": while it is 
a sensible operation to push the same branch-specifier to more than one 
repository, it does _not_ make sense to _fetch_ the same branch-specifier 
from more than one repository.

So multiple fetches would only make sense if you don't allow any branch 
specifiers (and then they'd be fetched from whatever branches the 
"remotes" file says). But that would make "git fetch" have two totally 
different modes, so that's not very good either.

And in the end, even a "git push all" that pushes to multiple repositories 
will actually end up connecting once for each repository, so it's really 
just a shorthand for doing multiple "git push"es. There's no real 
technical advantage, just a convenience.

So I'd suggest just doing

	git fetch origin
	git fetch jejb-scsi-misc-2.6

separately. Sadly, there's not even any way to fake this out with a git 

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
More majordomo info at
Received on Wed Nov 01 03:32:39 2006

This archive was generated by hypermail 2.1.8 : 2006-11-01 03:33:39 EST