{"thread":{"id":"9606","subject":"\"git pull REMOTE\" question","startedAt":"2007-08-22T04:23:52Z","lastAt":"2007-08-22T20:29:36Z","messageCount":6,"participants":["Miles Bader","Junio C Hamano","Jon Loeliger"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"51218","messageId":"fc339e4a0708212123p6e922b4cy3f5f19bfafafa395@mail.gmail.com","threadId":"9606","inReplyTo":null,"subject":"\"git pull REMOTE\" question","fromName":"Miles Bader","fromEmail":"miles@gnu.org","sentAt":"2007-08-22T04:23:52Z","receivedAt":"2007-08-22T04:23:52Z","isPatch":false,"sender":{"key":"miles@gnu.org","avatar":"https://gravatar.com/avatar/01069b69593af7bff28e2f97afeb3644ae6fe2f5f56cb3a8cf34c5fb8c36efe5?d=mp&s=160"},"body":"Hi,\n\nI have a .git/config file in my tree that looks like:\n\n   [remote \"origin\"]\n           url = ssh://HOST.org/home/miles/git/PROJECT.git\n           fetch = +refs/heads/*:refs/remotes/origin/*\n   [remote \"usb\"]\n           url = /media/usb/git/PROJECT.git\n           fetch = +refs/heads/*:refs/remotes/usb/*\n   [branch \"master\"]\n           remote = origin\n           merge = refs/heads/master\n\nand I'm normally using branch \"master\".\n\n\"git pull\" or \"git push\", without arguments, do exactly the right thing for\ninteracting with the \"origin\" remote.\n\nWhen I want to push to \"usb\" (a usb thumbdrive), \"git push usb\" also does I\nwant, but \"git pull usb\" does not:  the git-fetch phase of the git-pull\ncorrectly fetches all the proper objects from the usb repository, but the\ngit-merge part of the git-pull fails with an error message like:\n\n   Warning: No merge candidate found because value of config option\n            \"branch.master.merge\" does not match any remote branch fetched.\n   No changes.\n\n[See end of this message for a more complete output of a the pull command.]\n\nAfter doing the pull, I can manually do the merge I want using a\ncommand like \"git merge remotes/usb/master\", but it's kind of annoying\nto have to do this every time.\n\n>From my experimentation, it seems that this is because the local\nbranch \"master\" can only ever be associated with one remote (\"origin\"\nin this case), and the \"branch.master.merge\" config _only_ applies to\nthat remote.\n\nIs there a way to set things up so that \"git pull REMOTE\"\nautomatically merges fetched branches when doing a non-default pull?\nIf not, wouldn't this be a good feature to add?\n\nThanks,\n\n-Miles\n\n\nHere's the complete output of the git-pull command:\n\n   $ git pull usb\n   remote: Generating pack...\n   remote: Done counting 59 objects.\n   remote: Result has 38 objects.\n   remote: Deltifying 38 objects...\n   remote:\n   Unpacking 38 objects...\n   remote: Total 38 (delta 21), reused 24 (delta 8)\n     97% (37/38) done 100% (38/38) done\n   * refs/remotes/usb/master: storing branch 'master' of /media/usb/git/PROJECT\n     commit: 243e656\n   * refs/remotes/usb/branch1: storing branch 'branch1' of\n/media/usb/git/PROJECT\n     commit: e08c6ac\n   * refs/remotes/usb/branch2: storing branch 'branch2' of\n/media/usb/git/PROJECT\n     commit: 8ad20e8\n   * refs/remotes/usb/branch3: storing branch 'branch3' of\n/media/usb/git/PROJECT\n     commit: e874f3d\n   Warning: No merge candidate found because value of config option\n            \"branch.master.merge\" does not match any remote branch fetched.\n   No changes.\n   $\n\n\n-- \nEverywhere is walking distance if you have the time.  -- Steven Wright\n"},{"id":"51221","messageId":"7vy7g4jids.fsf@gitster.siamese.dyndns.org","threadId":"9606","inReplyTo":"fc339e4a0708212123p6e922b4cy3f5f19bfafafa395@mail.gmail.com","subject":"Re: \"git pull REMOTE\" question","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-08-22T04:35:59Z","receivedAt":"2007-08-22T04:35:59Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Miles Bader\" <miles@gnu.org> writes:\n\n> Is there a way to set things up so that \"git pull REMOTE\"\n> automatically merges fetched branches when doing a non-default pull?\n\nThe branch to be merged currently is determined per branch.\nYou can just say \"git pull usb master\".\n"},{"id":"51222","messageId":"buo8x84kwkq.fsf@dhapc248.dev.necel.com","threadId":"9606","inReplyTo":"7vy7g4jids.fsf@gitster.siamese.dyndns.org","subject":"Re: \"git pull REMOTE\" question","fromName":"Miles Bader","fromEmail":"miles.bader@necel.com","sentAt":"2007-08-22T04:44:05Z","receivedAt":"2007-08-22T04:44:05Z","isPatch":false,"sender":{"key":"miles.bader@necel.com","avatar":"https://gravatar.com/avatar/be062d4050eb88e04229cbdb60f803e1bd647923a015996c2439e76f23e336a7?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n>> Is there a way to set things up so that \"git pull REMOTE\"\n>> automatically merges fetched branches when doing a non-default pull?\n>\n> The branch to be merged currently is determined per branch.\n> You can just say \"git pull usb master\".\n\nRight, but what I'm asking is whether there is (or should be) a way to\nautomatically supply the \"master\", so I can just type \"git pull usb\" and\nhave it do the right thing -- as there obviously is for the \"origin\"\nremote for this branch.\n\nThis apparent association of each local branch with a single remote\nseems slightly odd to me -- isn't it quite common for people to pull\nfrom various different remotes into the same local branch (e.g. for\nsomeone merging from the repositories of various regular contributors)?\n\nThanks,\n\n-Miles\n\n-- \nDo not taunt Happy Fun Ball.\n"},{"id":"51223","messageId":"7vtzqsjgq2.fsf@gitster.siamese.dyndns.org","threadId":"9606","inReplyTo":"buo8x84kwkq.fsf@dhapc248.dev.necel.com","subject":"Re: \"git pull REMOTE\" question","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-08-22T05:11:49Z","receivedAt":"2007-08-22T05:11:49Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Miles Bader <miles.bader@necel.com> writes:\n\n> This apparent association of each local branch with a single remote\n> seems slightly odd to me\n\nI share the feeling.  I think pulling from more than one remote\nis the norm, and moreover, pulling from more than one branch of\none remote (depending on which branch you are pulling into) is\nalso common.  I did not even want to have the \"when we are on\nthis branch we would pull from that branch of that remote\" we\ncurrently have to begin with, but this is what the list wanted,\nso there you are.\n\nI _think_ the right approach is:\n\n\tgit pull remote_name\n\nwhen the user does not tell git which branch he is interested in\nmerging should be to say:\n\n 1. Do we have an association of our current-branch and the\n    remote name that defines which branch to merge?  If so, use\n    it (we do not have this right now, except for the case where\n    remote_name matches branch.$current_branch.remote);\n\n 2. Do we have a map from (current-branch, remote_name) to the\n    branch to be merged?  If so, use it (we do not have this\n    right now).\n\n 3. Is there the primary branch remote side defines (aka\n    refs/remotes/remote_name/HEAD)?  If so, use it (we do not do\n    this at all);\n\nSo, how about extending the syntax for [branch $current_branch]\nsection of the config like this?\n\n ;; traditional -- when on \"master\", use '[remote \"origin\"] url'\n ;; and '[remote \"origin\"] fetch' to decide where to fetch from,\n ;; and merge their refs/heads/master to our branch.\n [branch \"master\"]\n \tremote = origin\n        merge = refs/heads/master\n\n ;; new -- when on \"master', and the user says to pull from \"usb\"\n ;; without saying which branch to merge, use '[remote \"usb\"] url'\n ;; and '[remote \"usb\"] fetch' to decide where to fetch from,\n ;; and merge their refs/heads/xprm to our branch.\n [branch \"master:usb\"]\n \tmerge = refs/heads/xprm\n\nThe trick in the new syntax is that you cannot have a colon in\nrefname, so there is no way for existing [branch $name] section\nto crash with the new style definition.\n"},{"id":"51269","messageId":"1187801063.15321.4.camel@ld0161-tx32","threadId":"9606","inReplyTo":"7vtzqsjgq2.fsf@gitster.siamese.dyndns.org","subject":"Re: \"git pull REMOTE\" question","fromName":"Jon Loeliger","fromEmail":"jdl@freescale.com","sentAt":"2007-08-22T16:44:23Z","receivedAt":"2007-08-22T16:44:23Z","isPatch":false,"sender":{"key":"jdl@jdl.com","avatar":"https://gravatar.com/avatar/75ce9a10b151acd2c28ec4ab2136dba7b2ff1634530bd04b155981a749d08a64?d=mp&s=160"},"body":"On Wed, 2007-08-22 at 00:11, Junio C Hamano wrote:\n\n> So, how about extending the syntax for [branch $current_branch]\n> section of the config like this?\n> \n>  ;; traditional -- when on \"master\", use '[remote \"origin\"] url'\n>  ;; and '[remote \"origin\"] fetch' to decide where to fetch from,\n>  ;; and merge their refs/heads/master to our branch.\n>  [branch \"master\"]\n>  \tremote = origin\n>         merge = refs/heads/master\n> \n>  ;; new -- when on \"master', and the user says to pull from \"usb\"\n>  ;; without saying which branch to merge, use '[remote \"usb\"] url'\n>  ;; and '[remote \"usb\"] fetch' to decide where to fetch from,\n>  ;; and merge their refs/heads/xprm to our branch.\n>  [branch \"master:usb\"]\n>  \tmerge = refs/heads/xprm\n> \n> The trick in the new syntax is that you cannot have a colon in\n> refname, so there is no way for existing [branch $name] section\n> to crash with the new style definition.\n\nWasn't there was a brief alternate notion to add a \"for <remote>\"\nclause and allowing something like this?:\n\n    [branch \"master\"]\n        merge = refs/heads/xprm for usb\n        merge = refs/heads/stuff for otherremote\n\nThanks,\njdl\n"},{"id":"51289","messageId":"7vmywjia8f.fsf@gitster.siamese.dyndns.org","threadId":"9606","inReplyTo":"1187801063.15321.4.camel@ld0161-tx32","subject":"Re: \"git pull REMOTE\" question","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-08-22T20:29:36Z","receivedAt":"2007-08-22T20:29:36Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jon Loeliger <jdl@freescale.com> writes:\n\n> On Wed, 2007-08-22 at 00:11, Junio C Hamano wrote:\n> ...\n>>  ;; new -- when on \"master', and the user says to pull from \"usb\"\n>>  ;; without saying which branch to merge, use '[remote \"usb\"] url'\n>>  ;; and '[remote \"usb\"] fetch' to decide where to fetch from,\n>>  ;; and merge their refs/heads/xprm to our branch.\n>>  [branch \"master:usb\"]\n>>  \tmerge = refs/heads/xprm\n>> \n>> The trick in the new syntax is that you cannot have a colon in\n>> refname, so there is no way for existing [branch $name] section\n>> to crash with the new style definition.\n>\n> Wasn't there was a brief alternate notion to add a \"for <remote>\"\n> clause and allowing something like this?:\n>\n>     [branch \"master\"]\n>         merge = refs/heads/xprm for usb\n>         merge = refs/heads/stuff for otherremote\n\nYeah, I remember that one (I do not think nobody implemented it,\nthough).  Thanks for reminding.\n\nSo...\n\n\t[branch \"master\"]\n        \tremote = origin\n                merge = refs/heads/xprm for usb\n                merge = refs/heads/stuff for otherremote\n                merge = refs/heads/master\n\nand when you are on your \"master\", \n\n\t$ git fetch\n        $ git pull\n\ngoes to \"origin\" (because you did not even say the remote name).\n\n\t$ git fetch usb\n        $ git pull usb\n\ngoes to \"usb\".  And \"git pull\" from such a nicknamed remote\nlooks up merge lines with \"for nickname\" to find the branch(es)\nto merge.  If there is no merge line with \"for nickname\" for the\nremote (e.g. \"git pull origin\" in the above example does not\nhave any), and if there is a merge line without \"for nickname\",\nthen that line can be used (e.g. \"git pull\" which is exactly the\nsame as \"git pull origin\" will use the 'master' branch from the\nremote).\n\nI think that is much easier to understand and maintain for the\nend users than the [branch \"master:usb\"].  The latter is wrong\nto begin with -- it is not about branch anymore.\n"}]}