{"thread":{"id":"48682","subject":"Why is there no force pull?","startedAt":"2018-06-09T19:11:25Z","lastAt":"2018-06-10T16:08:22Z","messageCount":5,"participants":["Christoph Böhmwalder","Elijah Newren","Ævar Arnfjörð Bjarmason","Torsten Bögershausen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"349820","messageId":"20180609190154.yl4ig6dxfihgm5qi@christoph-lap","threadId":"48682","inReplyTo":null,"subject":"Why is there no force pull?","fromName":"Christoph Böhmwalder","fromEmail":"christoph@boehmwalder.at","sentAt":"2018-06-09T19:01:54Z","receivedAt":"2018-06-09T19:11:25Z","isPatch":false,"sender":{"key":"christoph@boehmwalder.at","avatar":null},"body":"Hi,\n\nSince this is a use case that actually comes up quite often in\nday-to-day use, especially among git beginners, I was wondering: is\nthere a specific reason why a command like \"fetch changes from remote,\noverwriting everything in my current working directory including all\ncommits I've made\" doesn't exist? Now, I'm quite aware that something\nlike\n\n    $ git fetch origin/branch\n    $ git reset --hard origin/branch\n\nwill do the trick just fine, but (like I mentioned, especially for\nbeginners) this kind of seems like a crook. Why not have a single\ncommand for accomplishing this? Afterall we do have a `--force` flag on\n`git push`, which practically does the same thing in reverse.\n\nJust reaching out to get some input on this, as it seems like a quite\ncurious inconsistency to me.\n\n--\nRegards,\nChristoph\n"},{"id":"349823","messageId":"CABPp-BG9HQ4O8h7-b4oL7KLu+boe6-QV1fvcfW_4O3Rax3W_Hw@mail.gmail.com","threadId":"48682","inReplyTo":"20180609190154.yl4ig6dxfihgm5qi@christoph-lap","subject":"Re: Why is there no force pull?","fromName":"Elijah Newren","fromEmail":"newren@gmail.com","sentAt":"2018-06-09T20:04:30Z","receivedAt":"2018-06-09T20:04:35Z","isPatch":false,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"On Sat, Jun 9, 2018 at 12:01 PM, Christoph Böhmwalder\n<christoph@boehmwalder.at> wrote:\n> Hi,\n>\n> Since this is a use case that actually comes up quite often in\n> day-to-day use, especially among git beginners, I was wondering: is\n> there a specific reason why a command like \"fetch changes from remote,\n> overwriting everything in my current working directory including all\n> commits I've made\" doesn't exist? Now, I'm quite aware that something\n> like\n>\n>     $ git fetch origin/branch\n>     $ git reset --hard origin/branch\n>\n> will do the trick just fine, but (like I mentioned, especially for\n> beginners) this kind of seems like a crook. Why not have a single\n> command for accomplishing this? Afterall we do have a `--force` flag on\n> `git push`, which practically does the same thing in reverse.\n>\n> Just reaching out to get some input on this, as it seems like a quite\n> curious inconsistency to me.\n\nUpon reading the subject and before reading the body, I assumed you\nwere going to ask for a 'git pull --force' that would throw away\n*uncommitted* changes (i.e. do a 'git reset --hard HEAD' before the\nrest of the pull).  But then you asked for both uncommitted and\ncommitted changes to be thrown away.  That difference isn't something\nyou have to consider with a push.\n\nThat might be a reason such an option would be confusing, or it might\njust be a warning to document the option carefully.  Anyway, thought\nI'd mention it.\n"},{"id":"349826","messageId":"20180609202553.dvoirez5mi2r4ctk@christoph-lap","threadId":"48682","inReplyTo":"CABPp-BG9HQ4O8h7-b4oL7KLu+boe6-QV1fvcfW_4O3Rax3W_Hw@mail.gmail.com","subject":"Re: Why is there no force pull?","fromName":"Christoph Böhmwalder","fromEmail":"christoph@boehmwalder.at","sentAt":"2018-06-09T20:25:53Z","receivedAt":"2018-06-09T20:25:59Z","isPatch":false,"sender":{"key":"christoph@boehmwalder.at","avatar":null},"body":"On Sat, Jun 09, 2018 at 01:04:30PM -0700, Elijah Newren wrote:\n> Upon reading the subject and before reading the body, I assumed you\n> were going to ask for a 'git pull --force' that would throw away\n> *uncommitted* changes (i.e. do a 'git reset --hard HEAD' before the\n> rest of the pull).  But then you asked for both uncommitted and\n> committed changes to be thrown away.  That difference isn't something\n> you have to consider with a push.\n> \n> That might be a reason such an option would be confusing, or it might\n> just be a warning to document the option carefully.  Anyway, thought\n> I'd mention it.\n\nInteresting, I hadn't taken that first scenario into consideration at\nall. So I guess two very aptly named flags would be necessary to\nimplement this kind of feature...\n\n--\nRegards,\nChristoph\n"},{"id":"349827","messageId":"87h8mbwvlr.fsf@evledraar.gmail.com","threadId":"48682","inReplyTo":"CABPp-BG9HQ4O8h7-b4oL7KLu+boe6-QV1fvcfW_4O3Rax3W_Hw@mail.gmail.com","subject":"Re: Why is there no force pull?","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-06-09T20:30:56Z","receivedAt":"2018-06-09T20:31:02Z","isPatch":false,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Sat, Jun 09 2018, Elijah Newren wrote:\n\n> On Sat, Jun 9, 2018 at 12:01 PM, Christoph Böhmwalder\n> <christoph@boehmwalder.at> wrote:\n>> Hi,\n>>\n>> Since this is a use case that actually comes up quite often in\n>> day-to-day use, especially among git beginners, I was wondering: is\n>> there a specific reason why a command like \"fetch changes from remote,\n>> overwriting everything in my current working directory including all\n>> commits I've made\" doesn't exist? Now, I'm quite aware that something\n>> like\n>>\n>>     $ git fetch origin/branch\n>>     $ git reset --hard origin/branch\n>>\n>> will do the trick just fine, but (like I mentioned, especially for\n>> beginners) this kind of seems like a crook. Why not have a single\n>> command for accomplishing this? Afterall we do have a `--force` flag on\n>> `git push`, which practically does the same thing in reverse.\n>>\n>> Just reaching out to get some input on this, as it seems like a quite\n>> curious inconsistency to me.\n>\n> Upon reading the subject and before reading the body, I assumed you\n> were going to ask for a 'git pull --force' that would throw away\n> *uncommitted* changes (i.e. do a 'git reset --hard HEAD' before the\n> rest of the pull).  But then you asked for both uncommitted and\n> committed changes to be thrown away.  That difference isn't something\n> you have to consider with a push.\n>\n> That might be a reason such an option would be confusing, or it might\n> just be a warning to document the option carefully.  Anyway, thought\n> I'd mention it.\n\nMore generally, \"git pull\"'s params are passed to \"git fetch\", and then\nwe either \"git merge\" or \"git rebase\".\n\nThis proposed behavior doesn't fit into that at all.\n\nBut it would if we added a third mode, similar to how we added \"rebase\",\nwhere we'd dispatch to \"reset\" instead, so:\n\n    git pull --reset --hard\n\nMeaning (in the general case):\n\n    git fetch &&\n    git reset --hard @{u}\n"},{"id":"349864","messageId":"20180610161153.GA27202@atze2.lan","threadId":"48682","inReplyTo":"20180609190154.yl4ig6dxfihgm5qi@christoph-lap","subject":"Re: Why is there no force pull?","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2018-06-10T16:11:53Z","receivedAt":"2018-06-10T16:08:22Z","isPatch":false,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On Sat, Jun 09, 2018 at 09:01:54PM +0200, Christoph Böhmwalder wrote:\n> Hi,\n> \n> Since this is a use case that actually comes up quite often in\n> day-to-day use, especially among git beginners, I was wondering: is\n> there a specific reason why a command like \"fetch changes from remote,\n> overwriting everything in my current working directory including all\n> commits I've made\" doesn't exist? Now, I'm quite aware that something\n> like\n> \n>     $ git fetch origin/branch\n>     $ git reset --hard origin/branch\n\nThis is not exactly what you askeded for, but I tend not to recommend\npeople using \"git reset --hard\" at all.\nEither use a \"stash\", just in case.\n\nOr, in your case:\n$ git fetch origin  && git checkout origin/branch\n\nThis will put your working tree onto origin/branch.\n\nAs a bonus, in case that you have done commits, which are now no longer\nvisible, \"git reflog\" is typically able to find them.\n"}]}