{"thread":{"id":"22615","subject":"Separate default push/pull?","startedAt":"2010-02-11T16:36:04Z","lastAt":"2010-02-13T11:58:34Z","messageCount":8,"participants":["David Abrahams","Chris Packham","Jeff King","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"134240","messageId":"m2zl3fg26j.fsf@boostpro.com","threadId":"22615","inReplyTo":null,"subject":"Separate default push/pull?","fromName":"David Abrahams","fromEmail":"dave@boostpro.com","sentAt":"2010-02-11T16:36:04Z","receivedAt":"2010-02-11T16:36:04Z","isPatch":false,"sender":{"key":"dave@boostpro.com","avatar":"https://gravatar.com/avatar/df0921f05114687777894565de21c052fb137ba7c303a399528b43d08833f065?d=mp&s=160"},"body":"\nIf I am collaborating mostly with one other person, I typically want to\npull from his publicly-readable repo and push to mine (on which I have\nwrite permission).  Is there any way to set things up so “git pull” and\n“git push” without additional arguments will do this by default?\n\nThanks,\n\n-- \nDave Abrahams           Meet me at BoostCon: http://www.boostcon.com\nBoostPro Computing\nhttp://www.boostpro.com\n"},{"id":"134250","messageId":"a038bef51002111057l382ed55fy6b4042d1115a830c@mail.gmail.com","threadId":"22615","inReplyTo":"m2zl3fg26j.fsf@boostpro.com","subject":"Re: Separate default push/pull?","fromName":"Chris Packham","fromEmail":"judge.packham@gmail.com","sentAt":"2010-02-11T18:57:34Z","receivedAt":"2010-02-11T18:57:34Z","isPatch":false,"sender":{"key":"judge.packham@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155667?v=4"},"body":"On Thu, Feb 11, 2010 at 11:36 AM, David Abrahams <dave@boostpro.com> wrote:\n>\n> If I am collaborating mostly with one other person, I typically want to\n> pull from his publicly-readable repo and push to mine (on which I have\n> write permission).  Is there any way to set things up so “git pull” and\n> “git push” without additional arguments will do this by default?\n>\n> Thanks,\n>\n> --\n> Dave Abrahams           Meet me at BoostCon: http://www.boostcon.com\n> BoostPro Computing\n> http://www.boostpro.com\n>\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>\n\nYes there is a way. I haven't used it myself but search this list and\nyou'll find plenty of references.\n\n(disclaimer: the following is what I think you can do based on some\nvague recollection and some man pages)\n\nTaking a quick look at the git push --help you'll see the following\nsnippet of configuration.\n\n                   [remote \"<name>\"]\n                           url = <url>\n                           pushurl = <pushurl>\n                           push = <refspec>\n                           fetch = <refspec>\n\nso I think if you just add the pushurl to your .git/config should do\nwhat you've asked\n\n[remote \"origin\"]\n        fetch = +refs/heads/*:refs/remotes/origin/*\n        url = git://git.kernel.org/pub/scm/git/git.git\n        pushurl = git://git.example.com/yourrepo.git\n\nFor your own sanity I suggest doing this by adding your repository as\na separate remote.\n\ne.g.\n\n  git remote add yourrepo git://git.example.com/yourrepo.git\n  git push yourrepo master:refs/heads/master  # the first time\n  git push yourrepo # subsequent times\n\nThere probably is a way to tell push to use something other than\n\"origin\" by default but I don't know/can't find it.\n"},{"id":"134279","messageId":"20100212001417.GC21930@coredump.intra.peff.net","threadId":"22615","inReplyTo":"a038bef51002111057l382ed55fy6b4042d1115a830c@mail.gmail.com","subject":"Re: Separate default push/pull?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-02-12T00:14:17Z","receivedAt":"2010-02-12T00:14:17Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Feb 11, 2010 at 01:57:34PM -0500, Chris Packham wrote:\n\n> Taking a quick look at the git push --help you'll see the following\n> snippet of configuration.\n> \n>                    [remote \"<name>\"]\n>                            url = <url>\n>                            pushurl = <pushurl>\n>                            push = <refspec>\n>                            fetch = <refspec>\n> \n> so I think if you just add the pushurl to your .git/config should do\n> what you've asked\n> \n> [remote \"origin\"]\n>         fetch = +refs/heads/*:refs/remotes/origin/*\n>         url = git://git.kernel.org/pub/scm/git/git.git\n>         pushurl = git://git.example.com/yourrepo.git\n\nThat's not quite what David wants, I think. That is a good recipe if you\nhave two ways of accessing the same repo (usually git:// for reading and\nssh for pushing). But if the two URLs actually point to _different_\nrepos, you will get some confusing results. For example, pushing to your\nprivate repo will update the tracking branches in refs/remotes/origin/*\nwith values that do not match what is in the actual origin repository.\n\n>   git remote add yourrepo git://git.example.com/yourrepo.git\n>   git push yourrepo master:refs/heads/master  # the first time\n>   git push yourrepo # subsequent times\n> \n> There probably is a way to tell push to use something other than\n> \"origin\" by default but I don't know/can't find it.\n\nI don't think there is currently a way to do what he wants. You can set\na default remote name by setting branch.*.remote, but that has two\nproblems:\n\n  1. It is also used to determine the upstream remote for pulling and\n     for calculating upstream tracking branches. So he probably wants to\n     leave it set as origin.\n\n  2. It would have to be set manually for every branch.\n\nI think what he would need is a \"push.defaultRemote\" config option,\nwhich universally overrides branch.*.remote for pushing.\n\n-Peff\n"},{"id":"134282","messageId":"7veikrl1m1.fsf@alter.siamese.dyndns.org","threadId":"22615","inReplyTo":"20100212001417.GC21930@coredump.intra.peff.net","subject":"Re: Separate default push/pull?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-02-12T00:49:26Z","receivedAt":"2010-02-12T00:49:26Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> I think what he would need is a \"push.defaultRemote\" config option,\n> which universally overrides branch.*.remote for pushing.\n\nOr \"branch.*.pushremote\".\n\nBut does it really make sense to get changes from one place and send\nchanges to somewhere completely unrelated?\n"},{"id":"134284","messageId":"20100212010549.GA23303@coredump.intra.peff.net","threadId":"22615","inReplyTo":"7veikrl1m1.fsf@alter.siamese.dyndns.org","subject":"Re: Separate default push/pull?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-02-12T01:05:49Z","receivedAt":"2010-02-12T01:05:49Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Feb 11, 2010 at 04:49:26PM -0800, Junio C Hamano wrote:\n\n> Jeff King <peff@peff.net> writes:\n> \n> > I think what he would need is a \"push.defaultRemote\" config option,\n> > which universally overrides branch.*.remote for pushing.\n> \n> Or \"branch.*.pushremote\".\n\nThat doesn't address my point 2, which is needing to set it up for every\nbranch.\n\n> But does it really make sense to get changes from one place and send\n> changes to somewhere completely unrelated?\n\nIt depends on your workflow. For git.git, your kernel.org repository is\nmy \"origin\", but I publish my state to a mirror for backup purposes (and\nI don't publish for others to view, but I could very well do that, too).\nI type \"git push peff.net\" and that is not too much trouble. Typing just\n\"git push\" would be slightly more convenient, though.\n\nIn a distributed setup, I don't think it is that uncommon to not want to\npush to the place you pull from. You are generally pulling and building\non somebody else's work, so if there is no central repo, you will be\npushing to somewhere that is not where you pulled it.\n\n-Peff\n"},{"id":"134287","messageId":"m2iqa3gp4q.wl%dave@boostpro.com","threadId":"22615","inReplyTo":"7veikrl1m1.fsf@alter.siamese.dyndns.org","subject":"Re: Separate default push/pull?","fromName":"David Abrahams","fromEmail":"dave@boostpro.com","sentAt":"2010-02-12T02:32:37Z","receivedAt":"2010-02-12T02:32:37Z","isPatch":false,"sender":{"key":"dave@boostpro.com","avatar":"https://gravatar.com/avatar/df0921f05114687777894565de21c052fb137ba7c303a399528b43d08833f065?d=mp&s=160"},"body":"At Thu, 11 Feb 2010 16:49:26 -0800,\nJunio C Hamano wrote:\n> \n> Jeff King <peff@peff.net> writes:\n> \n> > I think what he would need is a \"push.defaultRemote\" config option,\n> > which universally overrides branch.*.remote for pushing.\n> \n> Or \"branch.*.pushremote\".\n> \n> But does it really make sense to get changes from one place and send\n> changes to somewhere completely unrelated?\n\nIt's not unrelated; it's a publicly-readable clone of the source repo\nto which I have write permission.  After pushing changes there I send\na pull request to the owner of the source repo.\n\n-- \nDave Abrahams           Meet me at BoostCon: http://www.boostcon.com\nBoostPro Computing\nhttp://www.boostpro.com\n"},{"id":"134291","messageId":"7vvde3dmhp.fsf@alter.siamese.dyndns.org","threadId":"22615","inReplyTo":"20100212010549.GA23303@coredump.intra.peff.net","subject":"Re: Separate default push/pull?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-02-12T05:57:54Z","receivedAt":"2010-02-12T05:57:54Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> In a distributed setup, I don't think it is that uncommon to not want to\n> push to the place you pull from. You are generally pulling and building\n> on somebody else's work, so if there is no central repo, you will be\n> pushing to somewhere that is not where you pulled it.\n\nYou are probably right.\n\nIt still feels funny to see \"git pull\" and \"git push\" goes to different\nplaces, but as long as that is what the user explicitly configures, that's\nfine.\n"},{"id":"134423","messageId":"20100213115834.GA7385@coredump.intra.peff.net","threadId":"22615","inReplyTo":"7vvde3dmhp.fsf@alter.siamese.dyndns.org","subject":"Re: Separate default push/pull?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-02-13T11:58:34Z","receivedAt":"2010-02-13T11:58:34Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Feb 11, 2010 at 09:57:54PM -0800, Junio C Hamano wrote:\n\n> Jeff King <peff@peff.net> writes:\n> \n> > In a distributed setup, I don't think it is that uncommon to not want to\n> > push to the place you pull from. You are generally pulling and building\n> > on somebody else's work, so if there is no central repo, you will be\n> > pushing to somewhere that is not where you pulled it.\n> \n> You are probably right.\n> \n> It still feels funny to see \"git pull\" and \"git push\" goes to different\n> places, but as long as that is what the user explicitly configures, that's\n> fine.\n\nBy the way, I am a little iffy on the configuration I suggested. Even\nthough it matches David's workflow, it seems unintuitive to me that a\n\"push.defaultremote\" variable would override what's in \"branch.*.remote\".\n\n-Peff\n"}]}