{"thread":{"id":"17958","subject":"How do I undo a fast-forward merge safely?","startedAt":"2009-02-22T19:15:51Z","lastAt":"2009-02-24T05:37:38Z","messageCount":3,"participants":["Brent Goodrick","Jakub Narebski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"105816","messageId":"e38bce640902221115o2dd1c63dv6f7acc374b48d418@mail.gmail.com","threadId":"17958","inReplyTo":null,"subject":"How do I undo a fast-forward merge safely?","fromName":"Brent Goodrick","fromEmail":"bgoodr@gmail.com","sentAt":"2009-02-22T19:15:51Z","receivedAt":"2009-02-22T19:15:51Z","isPatch":false,"sender":{"key":"bgoodr@gmail.com","avatar":"https://gravatar.com/avatar/2399bf5a3468b3516a892183edfd43a7fa0300a2e9d5072189020186961150bc?d=mp&s=160"},"body":"I had done a git merge --no-commit <source_branch> operation, but that\nbit me because I mistakingly concluded that --no-commit would prevent\nany type of automatic operation, but apparently a fast-forward\noccurred.  I should have used the --no-ff option? How do I get my\ntarget branch back to where it was before the bad merge?\n\nI did make a backup of the entire repo before I started, so I do have\nthe plan-B option of replay my changes onto a copy of the backup repo.\n  But, maintaining backup copies just so as to avoid getting bit each\ntime I forget to use the --no-ff option will be a non-starter, so I\nwould hope there are some safe commands I can use to go back to the\noriginal.\n\ngit log -1 does not show the commit, but gitk does show a vertical red\nline that I can only presume indicates the fast-forward.  How does\ngitk determine that red line, while git-log does not?  Note that I\nhave not pulled into any other repo's yet, and won't until I can\nrectify this issue.\n\nHere was my bad git merge command line:\n\n$ git merge --no-commit source_branch\nUpdating 7eb9a02..0c66ca1\nFast forward\n<eliding list of files I want mixed in with lots of files I don't want>\n\nSo, what operations, rebase, reset, etc, do I need to do to get this\nrepo back to where it was right before the fast-forward?\n\nThanks,\nBrent\n"},{"id":"105817","messageId":"m3fxi6s0vu.fsf@localhost.localdomain","threadId":"17958","inReplyTo":"e38bce640902221115o2dd1c63dv6f7acc374b48d418@mail.gmail.com","subject":"Re: How do I undo a fast-forward merge safely?","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2009-02-22T19:54:47Z","receivedAt":"2009-02-22T19:54:47Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Brent Goodrick <bgoodr@gmail.com> writes:\n\n> I had done a git merge --no-commit <source_branch> operation, but that\n> bit me because I mistakingly concluded that --no-commit would prevent\n> any type of automatic operation, but apparently a fast-forward\n> occurred.  I should have used the --no-ff option? How do I get my\n> target branch back to where it was before the bad merge?\n\n[...]\n> So, what operations, rebase, reset, etc, do I need to do to get this\n> repo back to where it was right before the fast-forward?\n\nEach 'large' operation sets ORIG_HEAD\n\n  $ git reset --hard ORIG_HEAD\n\nIf you want to be more careful, examine reflog for HEAD, using either\n\"git reflog\" or \"git log -g\", and you can reset to previous version of\nHEAD (i.e. where current branch pointed to before 'git fetch') with\n\n  $ git reset --hard HEAD@{1}\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"105975","messageId":"e38bce640902232137s622410cv4506b8e0083bb468@mail.gmail.com","threadId":"17958","inReplyTo":"m3fxi6s0vu.fsf@localhost.localdomain","subject":"Re: How do I undo a fast-forward merge safely?","fromName":"Brent Goodrick","fromEmail":"bgoodr@gmail.com","sentAt":"2009-02-24T05:37:38Z","receivedAt":"2009-02-24T05:37:38Z","isPatch":false,"sender":{"key":"bgoodr@gmail.com","avatar":"https://gravatar.com/avatar/2399bf5a3468b3516a892183edfd43a7fa0300a2e9d5072189020186961150bc?d=mp&s=160"},"body":"On Sun, Feb 22, 2009 at 11:54 AM, Jakub Narebski <jnareb@gmail.com> wrote:\n> > So, what operations, rebase, reset, etc, do I need to do to get this\n> > repo back to where it was right before the fast-forward?\n>\n> Each 'large' operation sets ORIG_HEAD\n>\n>  $ git reset --hard ORIG_HEAD\n>\n\nThanks Jakub. \"git reset --hard ORIG_HEAD\" was what I went with and it\nworked like a charm!\n\nbg\n"}]}