{"thread":{"id":"20956","subject":"Per-remote tracking branch","startedAt":"2009-09-15T15:29:58Z","lastAt":"2009-09-24T16:00:07Z","messageCount":6,"participants":["Matthieu Moy","Jeff King","Björn Steinbrink"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"123265","messageId":"vpq4or48bux.fsf@bauges.imag.fr","threadId":"20956","inReplyTo":null,"subject":"Per-remote tracking branch","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2009-09-15T15:29:58Z","receivedAt":"2009-09-15T15:29:58Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Hi,\n\nIs there a way, with Git, to specify a tracking branch on a per-remote\nbasis?\n\nAt the moment, I can configure a tracking branch to let me just type\n\n$ git pull\n\nwhen I want to say\n\n$ git pull origin master\n\nNow, assume I have another remote \"foo\", I'd like to be able to just\nsay\n\n$ git pull foo\n\nand put something in my .git/config so that Git knows I mean\n\n$ git pull foo master\n\nIs there a simple way to do that?\n\n\n(for the motivation: I mostly use Git with a 1-branch-per-repo setup,\nso in 99% of my use-cases, when I have to specify a branch, it's\nmaster).\n\nThanks,\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"123715","messageId":"20090924062911.GC24486@coredump.intra.peff.net","threadId":"20956","inReplyTo":"vpq4or48bux.fsf@bauges.imag.fr","subject":"Re: Per-remote tracking branch","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-09-24T06:29:12Z","receivedAt":"2009-09-24T06:29:12Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Sep 15, 2009 at 05:29:58PM +0200, Matthieu Moy wrote:\n\n> Is there a way, with Git, to specify a tracking branch on a per-remote\n> basis?\n\nI don't think so, and I'm not sure there is an easy way to extend the\ncurrent configuration scheme. Adding multiple config options like this:\n\n  [branch \"master\"]\n    remote = origin\n    merge = refs/heads/master\n    remote = alternate\n    merge = refs/heads/master\n\nlooks a bit hack-ish to me, as there is an implicit correlation between\nthe ordering of 'merge' entries and 'remote' entries.\n\nAnd it feels a little backwards. When I say \"git pull foo\", I would find\nit equally likely to discover the pulled branch under \"remote.foo\" as it\nwould to find it under \"branch.master\". Of course, in either case, you\nhave to combine the context (current branch _and_ selected remote)\nto come up with the actual information. So I guess either is \"equally\ncorrect\" in a sense.\n\nAnyway, mostly just my idle speculation.\n\n-Peff\n"},{"id":"123727","messageId":"vpq63b8egy7.fsf@bauges.imag.fr","threadId":"20956","inReplyTo":"20090924062911.GC24486@coredump.intra.peff.net","subject":"Re: Per-remote tracking branch","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2009-09-24T11:10:40Z","receivedAt":"2009-09-24T11:10:40Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Hi, and thanks for your answer,\n\nJeff King <peff@peff.net> writes:\n\n> On Tue, Sep 15, 2009 at 05:29:58PM +0200, Matthieu Moy wrote:\n>\n>> Is there a way, with Git, to specify a tracking branch on a per-remote\n>> basis?\n>\n> I don't think so, and I'm not sure there is an easy way to extend the\n> current configuration scheme. Adding multiple config options like this:\n>\n>   [branch \"master\"]\n>     remote = origin\n>     merge = refs/heads/master\n>     remote = alternate\n>     merge = refs/heads/master\n\nI had tried this in case it would have worked ;-).\n\n> And it feels a little backwards. When I say \"git pull foo\", I would find\n> it equally likely to discover the pulled branch under \"remote.foo\" as it\n> would to find it under \"branch.master\". Of course, in either case, you\n> have to combine the context (current branch _and_ selected remote)\n> to come up with the actual information.\n\nActually, for my particular use case (aka \"almost always only one\nbranch per repo\"), I could as well have a remote.foo.defaultBranch\nregardless of the current local branch. Then, if I say \"git pull foo\",\nit would understand it as \"git pull foo <remote.foo.defaultBranch>\".\n\nIf other people would be interested in such feature, say so, I may\ngive it a try when I have time. If I'm the only one, I guess I'll let\nmy fingers type the extra \" master\" instead ;-).\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"123729","messageId":"20090924112550.GA6540@atjola.homenet","threadId":"20956","inReplyTo":"vpq4or48bux.fsf@bauges.imag.fr","subject":"Re: Per-remote tracking branch","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2009-09-24T11:25:50Z","receivedAt":"2009-09-24T11:25:50Z","isPatch":false,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2009.09.15 17:29:58 +0200, Matthieu Moy wrote:\n> Hi,\n> \n> Is there a way, with Git, to specify a tracking branch on a per-remote\n> basis?\n> \n> At the moment, I can configure a tracking branch to let me just type\n> \n> $ git pull\n> \n> when I want to say\n> \n> $ git pull origin master\n> \n> Now, assume I have another remote \"foo\", I'd like to be able to just\n> say\n> \n> $ git pull foo\n> \n> and put something in my .git/config so that Git knows I mean\n> \n> $ git pull foo master\n> \n> Is there a simple way to do that?\n\nSetup \"foo\" so that it fetches \"master\" only, i.e. have\nremote.foo.fetch = refs/heads/master:refs/remotes/foo/master\n\nYou get that setup with: git remote add -t master foo git://...\n\nThen there's only one possible choice for \"git pull\", and it will take\nthat.\n\nBjörn\n"},{"id":"123730","messageId":"20090924113537.GA14113@atjola.homenet","threadId":"20956","inReplyTo":"20090924112550.GA6540@atjola.homenet","subject":"Re: Per-remote tracking branch","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2009-09-24T11:35:37Z","receivedAt":"2009-09-24T11:35:37Z","isPatch":false,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2009.09.24 13:25:50 +0200, Björn Steinbrink wrote:\n> On 2009.09.15 17:29:58 +0200, Matthieu Moy wrote:\n> > At the moment, I can configure a tracking branch to let me just type\n> > \n> > $ git pull\n> > \n> > when I want to say\n> > \n> > $ git pull origin master\n> > \n> > Now, assume I have another remote \"foo\", I'd like to be able to just\n> > say\n> > \n> > $ git pull foo\n> > \n> > and put something in my .git/config so that Git knows I mean\n> > \n> > $ git pull foo master\n> > \n> > Is there a simple way to do that?\n> \n> Setup \"foo\" so that it fetches \"master\" only, i.e. have\n> remote.foo.fetch = refs/heads/master:refs/remotes/foo/master\n> \n> You get that setup with: git remote add -t master foo git://...\n> \n> Then there's only one possible choice for \"git pull\", and it will take\n> that.\n\nAh, crap, spoke too soon. That works only when branch.<name>.merge is\nnot set. Though that's not that much of a problem. When your \"primary\"\nremote (the one set for branch.<name>.remote) also fetches just a single\nbranch, \"git pull\" will still work, even if branch.<name>.merge is not\nset.\n\nBjörn\n"},{"id":"123739","messageId":"vpqskec5o54.fsf@bauges.imag.fr","threadId":"20956","inReplyTo":"20090924113537.GA14113@atjola.homenet","subject":"Re: Per-remote tracking branch","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2009-09-24T16:00:07Z","receivedAt":"2009-09-24T16:00:07Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Björn Steinbrink <B.Steinbrink@gmx.de> writes:\n\n>> Setup \"foo\" so that it fetches \"master\" only, i.e. have\n>> remote.foo.fetch = refs/heads/master:refs/remotes/foo/master\n>> \n>> You get that setup with: git remote add -t master foo git://...\n>> \n>> Then there's only one possible choice for \"git pull\", and it will take\n>> that.\n>\n> Ah, crap, spoke too soon. That works only when branch.<name>.merge is\n> not set. Though that's not that much of a problem. When your \"primary\"\n> remote (the one set for branch.<name>.remote) also fetches just a single\n> branch, \"git pull\" will still work, even if branch.<name>.merge is not\n> set.\n\nYes, that's it. Thanks for your anwser, it works.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"}]}