{"thread":{"id":"8215","subject":"Git branching & pulling","startedAt":"2007-05-19T05:40:17Z","lastAt":"2007-05-23T09:49:43Z","messageCount":12,"participants":["Wink Saville","J. Bruce Fields","Junio C Hamano","Steven Grimm","Josef Weidendorfer","Paolo Bonzini"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"42591","messageId":"d4cf37a60705182240s414243a6wae69d26f70f64dd5@mail.gmail.com","threadId":"8215","inReplyTo":null,"subject":"Git branching & pulling","fromName":"Wink Saville","fromEmail":"wink@saville.com","sentAt":"2007-05-19T05:40:17Z","receivedAt":"2007-05-19T05:40:17Z","isPatch":false,"sender":{"key":"wink@saville.com","avatar":"https://avatars.githubusercontent.com/u/1024284?v=4"},"body":"Hello,\n\nI'm having trouble understanding branching and pull.\n\nUsing git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git\nI can create a branch off the master and do a pull:\n\nwink@ic2d1:~/linux/linux-2.6$ git-checkout master\nSwitched to branch \"master\"\nwink@ic2d1:~/linux/linux-2.6$ git-checkout -b test\nSwitched to a new branch \"test\"\nwink@ic2d1:~/linux/linux-2.6$ git-pull\nAlready up-to-date.\n\n\n\nBut from some reason using\ngit://git.kernel.org/pub/scm/linux/kernel/git/avi/kvm.git\nthe following happens\n\nwink@ic2d1:~/linux/kvm-linux-2.6$ git-checkout master\nAlready on branch \"master\"\nwink@ic2d1:~/linux/kvm-linux-2.6$ git-checkout -b test\nSwitched to a new branch \"test\"\nwink@ic2d1:~/linux/kvm-linux-2.6$ git-pull\nWarning: No merge candidate found because value of config option\n         \"branch.test.merge\" does not match any remote branch fetched.\nNo changes.\n\n\n\nWhat I notice is that in kvm.git that .git/remotes is empty while on\nlinux-2.6.git\n.git/remotes has origin and it contains:\n\nURL: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git\nPull: refs/heads/master:refs/heads/origin\n\n\nAnother difference is that the .git/config file of kvm.git has quite a\nfew items:\n\n[core]\n repositoryformatversion = 0\n filemode = true\n bare = false\n logallrefupdates = true\n[remote \"origin\"]\n url = git://git.kernel.org/pub/scm/linux/kernel/git/avi/kvm.git\n fetch = +refs/heads/*:refs/remotes/origin/*\n[branch \"master\"]\n remote = origin\n merge = refs/heads/master\n\n\n\nWhile linux-2.6.git is quite sparse:\n\n[core]\n        repositoryformatversion = 0\n        filemode = true\n\n\n\nCould someone give me some insight or point me at a url or doc\nthat could shed some light on what is happening and why git-pull\ndoesn't work on kvm.git.\n\nThanks,\n\nWink Saville\n"},{"id":"42594","messageId":"20070519054936.GC2679@fieldses.org","threadId":"8215","inReplyTo":"d4cf37a60705182240s414243a6wae69d26f70f64dd5@mail.gmail.com","subject":"Re: Git branching & pulling","fromName":"J. Bruce Fields","fromEmail":"bfields@fieldses.org","sentAt":"2007-05-19T05:49:36Z","receivedAt":"2007-05-19T05:49:36Z","isPatch":false,"sender":{"key":"bfields@citi.umich.edu","avatar":null},"body":"On Fri, May 18, 2007 at 10:40:17PM -0700, Wink Saville wrote:\n> Hello,\n> \n> I'm having trouble understanding branching and pull.\n> \n> Using git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git\n> I can create a branch off the master and do a pull:\n> \n> wink@ic2d1:~/linux/linux-2.6$ git-checkout master\n> Switched to branch \"master\"\n> wink@ic2d1:~/linux/linux-2.6$ git-checkout -b test\n> Switched to a new branch \"test\"\n> wink@ic2d1:~/linux/linux-2.6$ git-pull\n> Already up-to-date.\n> \n> \n> \n> But from some reason using\n> git://git.kernel.org/pub/scm/linux/kernel/git/avi/kvm.git\n> the following happens\n> \n> wink@ic2d1:~/linux/kvm-linux-2.6$ git-checkout master\n> Already on branch \"master\"\n> wink@ic2d1:~/linux/kvm-linux-2.6$ git-checkout -b test\n> Switched to a new branch \"test\"\n> wink@ic2d1:~/linux/kvm-linux-2.6$ git-pull\n> Warning: No merge candidate found because value of config option\n>         \"branch.test.merge\" does not match any remote branch fetched.\n> No changes.\n\nThe differences you describe are almost certainly due to differences in\nthe git version, not the cloned repository.  Are you sure git wasn't\nugpraded between the two tests?\n\n--b.\n"},{"id":"42595","messageId":"7v8xblz71o.fsf@assigned-by-dhcp.cox.net","threadId":"8215","inReplyTo":"d4cf37a60705182240s414243a6wae69d26f70f64dd5@mail.gmail.com","subject":"Re: Git branching & pulling","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-05-19T06:00:51Z","receivedAt":"2007-05-19T06:00:51Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Wink Saville\" <wink@saville.com> writes:\n\n> Could someone give me some insight or point me at a url or doc\n> that could shed some light on what is happening and why git-pull\n> doesn't work on kvm.git.\n\nDEFAULT BEHAVIOUR section of\n\n    http://www.kernel.org/pub/software/scm/git/docs/git-pull.html \n\nwould be the place to start.  Recent git-clone (post 1.5.0, I think)\nprepares the following configuration variables for you by default:\n\n        remote.origin.url\n        remote.origin.fetch\n\tbranch.master.remote\n        branch.master.merge\n\nbut repositories created by older git-clone didn't.\n"},{"id":"42597","messageId":"7vzm41xsa2.fsf@assigned-by-dhcp.cox.net","threadId":"8215","inReplyTo":"7v8xblz71o.fsf@assigned-by-dhcp.cox.net","subject":"Re: Git branching & pulling","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-05-19T06:05:09Z","receivedAt":"2007-05-19T06:05:09Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <junkio@cox.net> writes:\n\n> \"Wink Saville\" <wink@saville.com> writes:\n>\n>> Could someone give me some insight or point me at a url or doc\n>> that could shed some light on what is happening and why git-pull\n>> doesn't work on kvm.git.\n>\n> DEFAULT BEHAVIOUR section of\n>\n>     http://www.kernel.org/pub/software/scm/git/docs/git-pull.html \n>\n> would be the place to start.  Recent git-clone (post 1.5.0, I think)\n> prepares the following configuration variables for you by default:\n>\n>         remote.origin.url\n>         remote.origin.fetch\n> \tbranch.master.remote\n>         branch.master.merge\n>\n> but repositories created by older git-clone didn't.\n\n\t/me says \"oops I did not finish the sentence\".\n\nbut repositories created by older git-clone didn't get these\nconfiguration variables set.  If you set them appropriately,\ntaking example of your other repository (and probably you would\nalso want to remove .git/remotes/origin while you are at it),\nyou can omit saying which branch to pull from where.\n\nI personally never understood why people would just want to say\n\"git pull\" without saying anything else, but what described in\nthe DEFAULT BEHAVIOUR section is how it works.\n"},{"id":"42599","messageId":"464E97A4.4050702@midwinter.com","threadId":"8215","inReplyTo":"7vzm41xsa2.fsf@assigned-by-dhcp.cox.net","subject":"Re: Git branching & pulling","fromName":"Steven Grimm","fromEmail":"koreth@midwinter.com","sentAt":"2007-05-19T06:22:28Z","receivedAt":"2007-05-19T06:22:28Z","isPatch":false,"sender":{"key":"koreth@midwinter.com","avatar":"https://gravatar.com/avatar/71b4d2e8b62f168bdc9e9205341159e3567003b4f9e2127c617c5fa0a1f5bad2?d=mp&s=160"},"body":"Junio C Hamano wrote:\n> I personally never understood why people would just want to say\n> \"git pull\" without saying anything else, but what described in\n> the DEFAULT BEHAVIOUR section is how it works.\n>   \n\nI do that all the time, e.g. when I'm syncing the satellite repo on my \nlaptop with the mothership repo in my account on my company's server. \nThe satellite only ever talks to the mothership and I am always \ninterested in pulling down all the changes I've committed to the \nmothership during the day. So there's really no need to specify \nanything; I always want to keep the two fully in sync, and there's never \nany question about where I'm pulling from.\n\nI do a plain \"git pull\" in my clone of git.git too. I want all the \nlatest updates and I'm only ever fetching them from the official git repo.\n\nI can certainly imagine that if I were an integrator in charge of a \nmaster repo, I'd always want to explicitly pull from particular places.\n\n-Steve\n"},{"id":"42600","messageId":"7vveepxr7m.fsf@assigned-by-dhcp.cox.net","threadId":"8215","inReplyTo":"464E97A4.4050702@midwinter.com","subject":"Re: Git branching & pulling","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-05-19T06:28:13Z","receivedAt":"2007-05-19T06:28:13Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Steven Grimm <koreth@midwinter.com> writes:\n\n> Junio C Hamano wrote:\n>> I personally never understood why people would just want to say\n>> \"git pull\" without saying anything else, but what described in\n>> the DEFAULT BEHAVIOUR section is how it works.\n>>\n>\n> I do that all the time, e.g. when I'm syncing the satellite repo on my\n> laptop with the mothership repo in my account on my company's\n> server. The satellite only ever talks to the mothership and I am\n> always interested in pulling down all the changes I've committed to\n> the mothership during the day. So there's really no need to specify\n> anything; I always want to keep the two fully in sync, and there's\n> never any question about where I'm pulling from.\n>\n> I do a plain \"git pull\" in my clone of git.git too. I want all the\n> latest updates and I'm only ever fetching them from the official git\n> repo.\n\nAh, if you ever interact with only single remote repository,\nthen that is certainly a valid reason not to say anything else.\n\nAnd if you ever interact with only single branch of a single\nremote repository while on one branch, the current config scheme\nwould let you do that on any branch.\n"},{"id":"42630","messageId":"d4cf37a60705190931rca1187ap9b98becb6c7c3b2a@mail.gmail.com","threadId":"8215","inReplyTo":"7vveepxr7m.fsf@assigned-by-dhcp.cox.net","subject":"Re: Git branching & pulling","fromName":"Wink Saville","fromEmail":"wink@saville.com","sentAt":"2007-05-19T16:31:43Z","receivedAt":"2007-05-19T16:31:43Z","isPatch":false,"sender":{"key":"wink@saville.com","avatar":"https://avatars.githubusercontent.com/u/1024284?v=4"},"body":"> Ah, if you ever interact with only single remote repository,\n> then that is certainly a valid reason not to say anything else.\n\nFor reference my git version:\n\nwink@ic2d1:~/linux/kvm-linux-2.6$ git --version\ngit version 1.5.2.rc0.g520d\n\n\nThis is very close to my situation, except in the mothership\nis linux-2.6.git, kvm.git or git.git. So I have two primary objectives, first\nperiodically synchronize my repository with the remotes. Second, synchronize\nmy branches with their \"remotes\".\n\nMy expectations are that when I'm on a branch and do a git-pull with no\nparameters I should \"fetch\" from that branches \"remotes\" and \"merge\" into\nthe current branch. This is how linus's repo seems to work.\n\nBut with kvm.git it appears I need to be quite explicit:\n\nwink@ic2d1:~/linux/kvm-linux-2.6$ git-checkout -b test\nSwitched to a new branch \"test\"\nwink@ic2d1:~/linux/kvm-linux-2.6$ git-pull\nfatal: 'master': unable to chdir or not a git archive\nfatal: The remote end hung up unexpectedly\nCannot get the repository state from master\nwink@ic2d1:~/linux/kvm-linux-2.6$ git-pull .\nerror: Object 5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c is a tree, not a commit\nerror: Object 5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c is a tree, not a commit\nAlready up-to-date.\nwink@ic2d1:~/linux/kvm-linux-2.6$ git-pull . master\nAlready up-to-date.\nwink@ic2d1:~/linux/kvm-linux-2.6$\n\nSo to get consistent behavior it seems I should\nalways use the two parameter form. But the behavior\nwith no parameters was very convenient and less\nerror prone as the branch should always know\nfrom where it was cloned:)\n\nHere is another experiment cloning a local repo created\nwith 1.5.2-rc0 where tried git-pull's:\n\nwink@ic2d1:~$ git-clone testgit testgit-clone\nInitialized empty Git repository in /home/wink/testgit-clone/.git/\nremote: Generating pack...\nremote: Done counting 6 objects.\nremote: Deltifying 6 objects...\nremote: /6) done/6) done\nremote: Total 6 (delta 0), reused 0 (delta 0)\nIndexing 6 objects...\n 100% (6/6) done\n\n\nwink@ic2d1:~$ cd testgit-clone/\nwink@ic2d1:~/testgit-clone$ git-pull\nAlready up-to-date.\nwink@ic2d1:~/testgit-clone$ git-pull .\nAlready up-to-date.\nwink@ic2d1:~/testgit-clone$ git-pull ../testgit\nAlready up-to-date.\nwink@ic2d1:~/testgit-clone$ git-pull ../testgit master\nAlready up-to-date.\nwink@ic2d1:~/testgit-clone$ git-checkout -b test master\nSwitched to a new branch \"test\"\nwink@ic2d1:~/testgit-clone$ git-pull .\nAlready up-to-date.\nwink@ic2d1:~/testgit-clone$ git-pull . master\nAlready up-to-date.\nwink@ic2d1:~/testgit-clone$ git-pull\nWarning: No merge candidate found because value of config option\n         \"branch.test.merge\" does not match any remote branch fetched.\nNo changes.\nwink@ic2d1:~/testgit-clone$\n\n\nWhy did last git-pull generate the warning, this seems wrong?\n\nRegards,\n\nWink Saville\n"},{"id":"42868","messageId":"200705202230.24362.Josef.Weidendorfer@gmx.de","threadId":"8215","inReplyTo":"d4cf37a60705190931rca1187ap9b98becb6c7c3b2a@mail.gmail.com","subject":"Re: Git branching & pulling","fromName":"Josef Weidendorfer","fromEmail":"josef.weidendorfer@gmx.de","sentAt":"2007-05-20T20:30:24Z","receivedAt":"2007-05-20T20:30:24Z","isPatch":false,"sender":{"key":"josef.weidendorfer@gmx.de","avatar":null},"body":"On Saturday 19 May 2007, Wink Saville wrote:\n> wink@ic2d1:~/testgit-clone$ git-checkout -b test master\n> Switched to a new branch \"test\"\n> wink@ic2d1:~/testgit-clone$ git-pull .\n> Already up-to-date.\n> wink@ic2d1:~/testgit-clone$ git-pull . master\n> Already up-to-date.\n> wink@ic2d1:~/testgit-clone$ git-pull\n> Warning: No merge candidate found because value of config option\n>          \"branch.test.merge\" does not match any remote branch fetched.\n> No changes.\n> wink@ic2d1:~/testgit-clone$\n> \n> Why did last git-pull generate the warning, this seems wrong?\n\nBecause git does not know what to merge; there is no config entry\nfor \"branch.test.merge\", as the warning says. How would you reword\nthis warning to make it easier to understand?\n\nBut from your question, I assume that you expected git to have a\n\"branch.test.merge\" setting.\nWhat do you expect it to do? And why?\n\nIs my assumption correct that you want the last command to be equivalent\nto \"git-pull . master\"? And my further assumption, that you want this\nbecause you expect \"git pull\" to default to merging changes from its\nupstream (also when the upstream is local)?\n\nCreation of a branch from another local one never has created\n\"branch.x.remote\" or \"branch.x.merge\" entries. I am not even sure\nthat setting \"branch.x.remote\" to \".\" is working in the current version.\n\nBTW: There was some old behavior of \"git pull\" to always pull the master\nbranch from remote \"origin\" without any further parameters. I suppose that\nyou did not want this to happen in your example above ?!\n\nJosef\n"},{"id":"43009","messageId":"d4cf37a60705221722t2167a0e8x810689218b87fb39@mail.gmail.com","threadId":"8215","inReplyTo":"200705202230.24362.Josef.Weidendorfer@gmx.de","subject":"Re: Git branching & pulling","fromName":"Wink Saville","fromEmail":"wink@saville.com","sentAt":"2007-05-23T00:22:03Z","receivedAt":"2007-05-23T00:22:03Z","isPatch":false,"sender":{"key":"wink@saville.com","avatar":"https://avatars.githubusercontent.com/u/1024284?v=4"},"body":">\n> Because git does not know what to merge; there is no config entry\n> for \"branch.test.merge\", as the warning says. How would you reword\n> this warning to make it easier to understand?\n> But from your question, I assume that you expected git to have a\n> \"branch.test.merge\" setting.\n> What do you expect it to do? And why?\n>\n> Is my assumption correct that you want the last command to be equivalent\n> to \"git-pull . master\"? And my further assumption, that you want this\n> because you expect \"git pull\" to default to merging changes from its\n> upstream (also when the upstream is local)?\n\nYes, as you said below that was the old behavior and besides when\nthe branch was created git was told what the upstream was it seems\nreasonable that it remember that. When I clone a remote it does the\nright thing it would seem when I make a branch it would behave\nthe same.\n\n>\n> Creation of a branch from another local one never has created\n> \"branch.x.remote\" or \"branch.x.merge\" entries. I am not even sure\n> that setting \"branch.x.remote\" to \".\" is working in the current version.\n\nI tired to create the appropriate entries and it didn't work,\nbut maybe operator error.\n\n> BTW: There was some old behavior of \"git pull\" to always pull the master\n> branch from remote \"origin\" without any further parameters. I suppose that\n> you did not want this to happen in your example above ?!\n>\n\nI expected it to pull from its upstream (i.e. the branches parent).\n\nWink\n"},{"id":"43011","messageId":"7vwsz05qcq.fsf@assigned-by-dhcp.cox.net","threadId":"8215","inReplyTo":"d4cf37a60705221722t2167a0e8x810689218b87fb39@mail.gmail.com","subject":"Re: Git branching & pulling","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-05-23T00:35:33Z","receivedAt":"2007-05-23T00:35:33Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Wink Saville\" <wink@saville.com> writes:\n\n>> Creation of a branch from another local one never has created\n>> \"branch.x.remote\" or \"branch.x.merge\" entries. I am not even sure\n>> that setting \"branch.x.remote\" to \".\" is working in the current version.\n>\n> I tired to create the appropriate entries and it didn't work,\n> but maybe operator error.\n>\n>> BTW: There was some old behavior of \"git pull\" to always pull the master\n>> branch from remote \"origin\" without any further parameters. I suppose that\n>> you did not want this to happen in your example above ?!\n>\n> I expected it to pull from its upstream (i.e. the branches parent).\n\nWhile \"I branched and that means I will always merge from that\nbranch\" does not hold true for everybody, we do have an option\nto make that easy to work in recent git.  Look in git-branch\ndocumentation and check autosetupmerge configuration option.\n\nI notice that Paolo did not update Documentation/config.txt\nwhen he add this feature with 0746d19a; care to send in a patch\nto correct this?\n"},{"id":"43088","messageId":"4653CC2A.5070202@lu.unisi.ch","threadId":"8215","inReplyTo":"7vwsz05qcq.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH] Document branch.autosetupmerge.","fromName":"Paolo Bonzini","fromEmail":"paolo.bonzini@lu.unisi.ch","sentAt":"2007-05-23T05:07:54Z","receivedAt":"2007-05-23T05:07:54Z","isPatch":true,"sender":{"key":"bonzini@gnu.org","avatar":"https://avatars.githubusercontent.com/u/42082?v=4"},"body":"This patch documents the branch.autosetupmerge config option, adding\nin commit 0746d19a.\n\nSigned-Off-By: Paolo Bonzini  <bonzini@gnu.org>\n---\n\n  config.txt |    7 +++++++\n  1 files changed, 7 insertions(+)\n\n\t> I notice that Paolo did not update Documentation/config.txt\n\t> when he add this feature with 0746d19a; care to send in a patch\n\t> to correct this?\n\t\n\tSure.\n\n\tPaolo.\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 179cb17..de3c276 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -280,4 +280,11 @@ apply.whitespace::\n  \tTells `git-apply` how to handle whitespaces, in the same way\n  \tas the '--whitespace' option. See gitlink:git-apply[1].\n\n+branch.autosetupmerge::\n+\tTells `git-branch' and `git-checkout' to setup new branches\n+\tso that gitlink:git-pull[1] will appropriately merge from that\n+\tremote branch.  Note that even if this option is not set,\n+\tthis behavior can be chosen per-branch using the `--track`\n+\tand `--no-track` options.  This option defaults to false.\n+\n  branch.<name>.remote::\n"},{"id":"43025","messageId":"200705231149.43245.Josef.Weidendorfer@gmx.de","threadId":"8215","inReplyTo":"7vwsz05qcq.fsf@assigned-by-dhcp.cox.net","subject":"Re: Git branching & pulling","fromName":"Josef Weidendorfer","fromEmail":"josef.weidendorfer@gmx.de","sentAt":"2007-05-23T09:49:43Z","receivedAt":"2007-05-23T09:49:43Z","isPatch":false,"sender":{"key":"josef.weidendorfer@gmx.de","avatar":null},"body":"On Wednesday 23 May 2007, Junio C Hamano wrote:\n> \"Wink Saville\" <wink@saville.com> writes:\n> \n> >> Creation of a branch from another local one never has created\n> >> \"branch.x.remote\" or \"branch.x.merge\" entries. I am not even sure\n> >> that setting \"branch.x.remote\" to \".\" is working in the current version.\n> >\n> > I tired to create the appropriate entries and it didn't work,\n> > but maybe operator error.\n> >\n> >> BTW: There was some old behavior of \"git pull\" to always pull the master\n> >> branch from remote \"origin\" without any further parameters. I suppose that\n> >> you did not want this to happen in your example above ?!\n> >\n> > I expected it to pull from its upstream (i.e. the branches parent).\n> \n> While \"I branched and that means I will always merge from that\n> branch\" does not hold true for everybody, we do have an option\n> to make that easy to work in recent git.  Look in git-branch\n> documentation and check autosetupmerge configuration option.\n\nAh, I stand corrected: I just checked - git already allows to default\nto even a local upstream for \"git pull\", not only a remote tracking\nbranch.\n\nVery nice.\n\nWhat about making \"git rebase\" without arguments default to\nthe stored upstream?\n\nJosef\n"}]}