* Re: git fetch with multiple remotes failing?
2006-10-31 15:59 git fetch with multiple remotes failing? Michael S. Tsirkin
@ 2006-10-31 16:32 ` Linus Torvalds
2006-11-01 0:12 ` Petr Baudis
0 siblings, 1 reply; 3+ messages in thread
From: Linus Torvalds @ 2006-10-31 16:32 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: Git Mailing List
On Tue, 31 Oct 2006, Michael S. Tsirkin wrote:
>
> $ cat .git/remotes/origin
> URL: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
> Pull: +refs/heads/master:refs/heads/linus_master
> $ cat .git/remotes/jejb-scsi-misc-2.6
> URL: git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6.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://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.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 = master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6
url = login.osdl.org:linux-2.6.git
- 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
alias.
^ permalink raw reply [flat|nested] 3+ messages in thread