git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Per-remote tracking branch
@ 2009-09-15 15:29 Matthieu Moy
  2009-09-24  6:29 ` Jeff King
  2009-09-24 11:25 ` Björn Steinbrink
  0 siblings, 2 replies; 6+ messages in thread
From: Matthieu Moy @ 2009-09-15 15:29 UTC (permalink / raw)
  To: git

Hi,

Is there a way, with Git, to specify a tracking branch on a per-remote
basis?

At the moment, I can configure a tracking branch to let me just type

$ git pull

when I want to say

$ git pull origin master

Now, assume I have another remote "foo", I'd like to be able to just
say

$ git pull foo

and put something in my .git/config so that Git knows I mean

$ git pull foo master

Is there a simple way to do that?


(for the motivation: I mostly use Git with a 1-branch-per-repo setup,
so in 99% of my use-cases, when I have to specify a branch, it's
master).

Thanks,

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Per-remote tracking branch
  2009-09-15 15:29 Per-remote tracking branch Matthieu Moy
@ 2009-09-24  6:29 ` Jeff King
  2009-09-24 11:10   ` Matthieu Moy
  2009-09-24 11:25 ` Björn Steinbrink
  1 sibling, 1 reply; 6+ messages in thread
From: Jeff King @ 2009-09-24  6:29 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: git

On Tue, Sep 15, 2009 at 05:29:58PM +0200, Matthieu Moy wrote:

> Is there a way, with Git, to specify a tracking branch on a per-remote
> basis?

I don't think so, and I'm not sure there is an easy way to extend the
current configuration scheme. Adding multiple config options like this:

  [branch "master"]
    remote = origin
    merge = refs/heads/master
    remote = alternate
    merge = refs/heads/master

looks a bit hack-ish to me, as there is an implicit correlation between
the ordering of 'merge' entries and 'remote' entries.

And it feels a little backwards. When I say "git pull foo", I would find
it equally likely to discover the pulled branch under "remote.foo" as it
would to find it under "branch.master". Of course, in either case, you
have to combine the context (current branch _and_ selected remote)
to come up with the actual information. So I guess either is "equally
correct" in a sense.

Anyway, mostly just my idle speculation.

-Peff

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Per-remote tracking branch
  2009-09-24  6:29 ` Jeff King
@ 2009-09-24 11:10   ` Matthieu Moy
  0 siblings, 0 replies; 6+ messages in thread
From: Matthieu Moy @ 2009-09-24 11:10 UTC (permalink / raw)
  To: Jeff King; +Cc: git

Hi, and thanks for your answer,

Jeff King <peff@peff.net> writes:

> On Tue, Sep 15, 2009 at 05:29:58PM +0200, Matthieu Moy wrote:
>
>> Is there a way, with Git, to specify a tracking branch on a per-remote
>> basis?
>
> I don't think so, and I'm not sure there is an easy way to extend the
> current configuration scheme. Adding multiple config options like this:
>
>   [branch "master"]
>     remote = origin
>     merge = refs/heads/master
>     remote = alternate
>     merge = refs/heads/master

I had tried this in case it would have worked ;-).

> And it feels a little backwards. When I say "git pull foo", I would find
> it equally likely to discover the pulled branch under "remote.foo" as it
> would to find it under "branch.master". Of course, in either case, you
> have to combine the context (current branch _and_ selected remote)
> to come up with the actual information.

Actually, for my particular use case (aka "almost always only one
branch per repo"), I could as well have a remote.foo.defaultBranch
regardless of the current local branch. Then, if I say "git pull foo",
it would understand it as "git pull foo <remote.foo.defaultBranch>".

If other people would be interested in such feature, say so, I may
give it a try when I have time. If I'm the only one, I guess I'll let
my fingers type the extra " master" instead ;-).

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Per-remote tracking branch
  2009-09-15 15:29 Per-remote tracking branch Matthieu Moy
  2009-09-24  6:29 ` Jeff King
@ 2009-09-24 11:25 ` Björn Steinbrink
  2009-09-24 11:35   ` Björn Steinbrink
  1 sibling, 1 reply; 6+ messages in thread
From: Björn Steinbrink @ 2009-09-24 11:25 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: git

On 2009.09.15 17:29:58 +0200, Matthieu Moy wrote:
> Hi,
> 
> Is there a way, with Git, to specify a tracking branch on a per-remote
> basis?
> 
> At the moment, I can configure a tracking branch to let me just type
> 
> $ git pull
> 
> when I want to say
> 
> $ git pull origin master
> 
> Now, assume I have another remote "foo", I'd like to be able to just
> say
> 
> $ git pull foo
> 
> and put something in my .git/config so that Git knows I mean
> 
> $ git pull foo master
> 
> Is there a simple way to do that?

Setup "foo" so that it fetches "master" only, i.e. have
remote.foo.fetch = refs/heads/master:refs/remotes/foo/master

You get that setup with: git remote add -t master foo git://...

Then there's only one possible choice for "git pull", and it will take
that.

Björn

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Per-remote tracking branch
  2009-09-24 11:25 ` Björn Steinbrink
@ 2009-09-24 11:35   ` Björn Steinbrink
  2009-09-24 16:00     ` Matthieu Moy
  0 siblings, 1 reply; 6+ messages in thread
From: Björn Steinbrink @ 2009-09-24 11:35 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: git

On 2009.09.24 13:25:50 +0200, Björn Steinbrink wrote:
> On 2009.09.15 17:29:58 +0200, Matthieu Moy wrote:
> > At the moment, I can configure a tracking branch to let me just type
> > 
> > $ git pull
> > 
> > when I want to say
> > 
> > $ git pull origin master
> > 
> > Now, assume I have another remote "foo", I'd like to be able to just
> > say
> > 
> > $ git pull foo
> > 
> > and put something in my .git/config so that Git knows I mean
> > 
> > $ git pull foo master
> > 
> > Is there a simple way to do that?
> 
> Setup "foo" so that it fetches "master" only, i.e. have
> remote.foo.fetch = refs/heads/master:refs/remotes/foo/master
> 
> You get that setup with: git remote add -t master foo git://...
> 
> Then there's only one possible choice for "git pull", and it will take
> that.

Ah, crap, spoke too soon. That works only when branch.<name>.merge is
not set. Though that's not that much of a problem. When your "primary"
remote (the one set for branch.<name>.remote) also fetches just a single
branch, "git pull" will still work, even if branch.<name>.merge is not
set.

Björn

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Per-remote tracking branch
  2009-09-24 11:35   ` Björn Steinbrink
@ 2009-09-24 16:00     ` Matthieu Moy
  0 siblings, 0 replies; 6+ messages in thread
From: Matthieu Moy @ 2009-09-24 16:00 UTC (permalink / raw)
  To: Björn Steinbrink; +Cc: git

Björn Steinbrink <B.Steinbrink@gmx.de> writes:

>> Setup "foo" so that it fetches "master" only, i.e. have
>> remote.foo.fetch = refs/heads/master:refs/remotes/foo/master
>> 
>> You get that setup with: git remote add -t master foo git://...
>> 
>> Then there's only one possible choice for "git pull", and it will take
>> that.
>
> Ah, crap, spoke too soon. That works only when branch.<name>.merge is
> not set. Though that's not that much of a problem. When your "primary"
> remote (the one set for branch.<name>.remote) also fetches just a single
> branch, "git pull" will still work, even if branch.<name>.merge is not
> set.

Yes, that's it. Thanks for your anwser, it works.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-09-24 16:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-15 15:29 Per-remote tracking branch Matthieu Moy
2009-09-24  6:29 ` Jeff King
2009-09-24 11:10   ` Matthieu Moy
2009-09-24 11:25 ` Björn Steinbrink
2009-09-24 11:35   ` Björn Steinbrink
2009-09-24 16:00     ` Matthieu Moy

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).