{"thread":{"id":"9639","subject":"how do you \"force a pull\"?","startedAt":"2007-08-25T11:19:46Z","lastAt":"2007-08-27T05:26:31Z","messageCount":7,"participants":["Jing Xue","Dan Chokola","David Watson","Randal L. Schwartz","Fredrik Tolf"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"51501","messageId":"20070825111946.GA7122@falcon.digizenstudio.com","threadId":"9639","inReplyTo":null,"subject":"how do you \"force a pull\"?","fromName":"Jing Xue","fromEmail":"jingxue@digizenstudio.com","sentAt":"2007-08-25T11:19:46Z","receivedAt":"2007-08-25T11:19:46Z","isPatch":false,"sender":{"key":"jingxue@digizenstudio.com","avatar":null},"body":"I am working in repo1, and make a savepoint commit and pack up and leave.\n\nOn another machine, I have a clone of repo1 (repo2). So I pull from\nrepo1, \"git reset --soft HEAD\" to get rid of the savepoint commit, and start working in repo2.\n\nA while later I realize the earlier commit was actually a good commit\npoint. But I can no longer pull it again from repo1. It keeps giving me\nthe \"Cannot merge\" fatal error. \"-f\" doesn't help.\n\nSo in general my question is \"how do you force pulling from a remote\nrepository?\"  (short of, you know, recloning the repo...)\n\nI have a feeling that either I'm still stuck in the traditional central-repository\nmentality, or missing something real simple.\n\nThanks.\n-- \nJing Xue\n"},{"id":"51502","messageId":"61e816970708250431s1a05a30u992cfcde4f956e85@mail.gmail.com","threadId":"9639","inReplyTo":"20070825111946.GA7122@falcon.digizenstudio.com","subject":"Re: how do you \"force a pull\"?","fromName":"Dan Chokola","fromEmail":"dan@chokola.com","sentAt":"2007-08-25T11:31:45Z","receivedAt":"2007-08-25T11:31:45Z","isPatch":false,"sender":{"key":"dan@chokola.com","avatar":null},"body":"On 8/25/07, Jing Xue <jingxue@digizenstudio.com> wrote:\n> I am working in repo1, and make a savepoint commit and pack up and leave.\n>\n> On another machine, I have a clone of repo1 (repo2). So I pull from\n> repo1, \"git reset --soft HEAD\" to get rid of the savepoint commit, and start working in repo2.\n>\n> A while later I realize the earlier commit was actually a good commit\n> point. But I can no longer pull it again from repo1. It keeps giving me\n> the \"Cannot merge\" fatal error. \"-f\" doesn't help.\n>\n> So in general my question is \"how do you force pulling from a remote\n> repository?\"  (short of, you know, recloning the repo...)\n>\n> I have a feeling that either I'm still stuck in the traditional central-repository\n> mentality, or missing something real simple.\n>\n> Thanks.\n> --\n> Jing Xue\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\nI've had the same trouble and it also brings up the question, why\ncan't one fetch into the current branch? To work around git pull's\nbehavior, I generally either:\n- git reset --hard HEAD^^^^^^^ && git pull\n or\n- git checkout someotherbranch && git fetch -f origin master\n\nSo why doesn't pull -f understand that it should force an update to\nthe history? And is there some reason I'm missing for why fetch won't\nfetch on the current branch?\n\n-- \nDan Chokola\n"},{"id":"51503","messageId":"20070825113747.GA21030@mimvista.com","threadId":"9639","inReplyTo":"20070825111946.GA7122@falcon.digizenstudio.com","subject":"Re: how do you \"force a pull\"?","fromName":"David Watson","fromEmail":"dwatson@mimvista.com","sentAt":"2007-08-25T11:37:47Z","receivedAt":"2007-08-25T11:37:47Z","isPatch":false,"sender":{"key":"dwatson@mimvista.com","avatar":null},"body":"The commit you pulled should still be in your local repository (repo2),\nunless you've done something to deliberately remove it.\n\nIf you're using the default repository setup when cloning, then master\nbranch of repo1 should be available as origin/master, so you can do the\nfollowing:\n\n$ git reset --hard origin/master\n\nor log:\n\n$ git log origin/master\n\nIf you want to see all your branches, local or remote:\n\n$ git branch -r\n\nNote that you shouldn't checkout origin/master and work on it, but rather\nyou'll want to make a branch, and work on that:\n\n$ git co -b fancy_branch origin/master\n\nYou may be getting the \"cannot merge message\" if you have uncommitted\nchanges, as git won't let you merge when the working copy is changed.\ngit-pull is really git-fetch + git-merge.\n\nOn Sat, Aug 25, 2007 at 07:19:46AM -0400, Jing Xue wrote:\n> I am working in repo1, and make a savepoint commit and pack up and leave.\n> \n> On another machine, I have a clone of repo1 (repo2). So I pull from\n> repo1, \"git reset --soft HEAD\" to get rid of the savepoint commit, and start working in repo2.\n> \n> A while later I realize the earlier commit was actually a good commit\n> point. But I can no longer pull it again from repo1. It keeps giving me\n> the \"Cannot merge\" fatal error. \"-f\" doesn't help.\n> \n> So in general my question is \"how do you force pulling from a remote\n> repository?\"  (short of, you know, recloning the repo...)\n> \n> I have a feeling that either I'm still stuck in the traditional central-repository\n> mentality, or missing something real simple.\n> \n> Thanks.\n> -- \n> Jing Xue\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-- \nDave Watson\n"},{"id":"51504","messageId":"20070825115326.GB7122@falcon.digizenstudio.com","threadId":"9639","inReplyTo":"20070825113747.GA21030@mimvista.com","subject":"Re: how do you \"force a pull\"?","fromName":"Jing Xue","fromEmail":"jingxue@digizenstudio.com","sentAt":"2007-08-25T11:53:26Z","receivedAt":"2007-08-25T11:53:26Z","isPatch":false,"sender":{"key":"jingxue@digizenstudio.com","avatar":null},"body":"On Sat, Aug 25, 2007 at 07:37:47AM -0400, David Watson wrote:\n> $ git reset --hard origin/master\n\nAh, this is what I was looking for. Not very intuitive, but works like a\ncharm!\n\n> You may be getting the \"cannot merge message\" if you have uncommitted\n> changes, as git won't let you merge when the working copy is changed.\n> git-pull is really git-fetch + git-merge.\n\nRight, because I used \"--soft\" in the earlier reset.\n\nThanks!\n-- \nJing Xue\n"},{"id":"51505","messageId":"86odgveoq4.fsf@blue.stonehenge.com","threadId":"9639","inReplyTo":"20070825115326.GB7122@falcon.digizenstudio.com","subject":"Re: how do you \"force a pull\"?","fromName":"Randal L. Schwartz","fromEmail":"merlyn@stonehenge.com","sentAt":"2007-08-25T13:19:15Z","receivedAt":"2007-08-25T13:19:15Z","isPatch":false,"sender":{"key":"merlyn@stonehenge.com","avatar":"https://gravatar.com/avatar/dc528d210743ff0333e6213f9ee7b33b23f1b7bc1f3c5a8c2d819074ecd7ab19?d=mp&s=160"},"body":">>>>> \"Jing\" == Jing Xue <jingxue@digizenstudio.com> writes:\n\nJing> Ah, this is what I was looking for. Not very intuitive, but works like a\nJing> charm!\n\nI find the word \"intuitive\" is like \"common sense\", which apparently isn't\nvery common. :)\n\n\"Not very intuitive\" can be translated as \"I don't yet share the mental model\nfrom which this observation would be obvious\".\n\nI would suggest that to make such observations more intuitive, you stop\nthinking of git as you would SVN or (gasp!) CVS, and start paying attention to\nwhat git-fetch is really doing to the local object tree, and git-merge on top\nof that, collectively known as git-pull.\n\nThe concept of keeping track of a directed graph of commits is not present in\n\"classic\" source code managers... and once you make the mental leap, you'll\nwonder why it was ever done differently.  It's revolutionary, not just\nevolutionary.\n\n(And if this sounds meta, it's because I'm rewriting my \"intro to git\" slides\nbecause I just confirmed where my next presentation will be, and want them to\nbe even better.)\n\n-- \nRandal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095\n<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>\nPerl/Unix/security consulting, Technical writing, Comedy, etc. etc.\nSee PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!\n"},{"id":"51581","messageId":"m34pimdspt.fsf@pc7.dolda2000.com","threadId":"9639","inReplyTo":"20070825111946.GA7122@falcon.digizenstudio.com","subject":"Re: how do you \"force a pull\"?","fromName":"Fredrik Tolf","fromEmail":"fredrik@dolda2000.com","sentAt":"2007-08-26T19:02:54Z","receivedAt":"2007-08-26T19:02:54Z","isPatch":false,"sender":{"key":"fredrik@dolda2000.com","avatar":null},"body":"Jing Xue <jingxue@digizenstudio.com> writes:\n\n> I am working in repo1, and make a savepoint commit and pack up and leave.\n>\n> On another machine, I have a clone of repo1 (repo2). So I pull from\n> repo1, \"git reset --soft HEAD\" to get rid of the savepoint commit, and start working in repo2.\n>\n> A while later I realize the earlier commit was actually a good commit\n> point. But I can no longer pull it again from repo1. It keeps giving me\n> the \"Cannot merge\" fatal error. \"-f\" doesn't help.\n\nThis is probably not as good an answer as David Watson's suggestion,\nbut if what you want is to commit your current code while still having\nyour savepoint commit in the history, shouldn't you be able to commit\nyour current code and then use git-rebase to rebase it onto the\nsavepoint commit?\n\nFredrik Tolf\n"},{"id":"51633","messageId":"20070827052631.GA3580@falcon.digizenstudio.com","threadId":"9639","inReplyTo":"m34pimdspt.fsf@pc7.dolda2000.com","subject":"Re: how do you \"force a pull\"?","fromName":"Jing Xue","fromEmail":"jingxue@digizenstudio.com","sentAt":"2007-08-27T05:26:31Z","receivedAt":"2007-08-27T05:26:31Z","isPatch":false,"sender":{"key":"jingxue@digizenstudio.com","avatar":null},"body":"On Sun, Aug 26, 2007 at 09:02:54PM +0200, Fredrik Tolf wrote:\n> \n> This is probably not as good an answer as David Watson's suggestion,\n> but if what you want is to commit your current code while still having\n> your savepoint commit in the history, shouldn't you be able to commit\n> your current code and then use git-rebase to rebase it onto the\n> savepoint commit?\n\nYep, I tried and it works too. A bit more verbose than a hard reset -\ninvolved some manual merging in my case, had to update-index and then\n--continue the rebase. But then I think this approach is semantically\ndifferent and probably safer than a hard reset in some cases.\n\nAll this is interesting and good to know. Thanks, Fredrik!\n-- \nJing Xue\n"}]}