git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: How do I undo a fast-forward merge safely?

From
Jakub Narebski <jnareb@gmail.com>
Date
Feb 22, 2009, 19:54 UTC
Message-ID
<m3fxi6s0vu.fsf@localhost.localdomain>
In-Reply-To
<e38bce640902221115o2dd1c63dv6f7acc374b48d418@mail.gmail.com>
Brent Goodrick <bgoodr@gmail.com> writes:
Show 5 quoted lines
> I had done a git merge --no-commit <source_branch> operation, but that
> bit me because I mistakingly concluded that --no-commit would prevent
> any type of automatic operation, but apparently a fast-forward
> occurred.  I should have used the --no-ff option? How do I get my
> target branch back to where it was before the bad merge?
[...]
> So, what operations, rebase, reset, etc, do I need to do to get this
> repo back to where it was right before the fast-forward?
Each 'large' operation sets ORIG_HEAD
  $ git reset --hard ORIG_HEAD

If you want to be more careful, examine reflog for HEAD, using either "git reflog" or "git log -g", and you can reset to previous version of HEAD (i.e. where current branch pointed to before 'git fetch') with

  $ git reset --hard HEAD@{1}
-- 
Jakub Narebski
Poland
ShadeHawk on #git
Previous: Brent GoodrickNext: Brent Goodrick
Message 2 of 3 in “How do I undo a fast-forward merge safely?”
  1. Brent GoodrickFeb 22, 2009
  2. Jakub NarebskiFeb 22, 2009
  3. Brent GoodrickFeb 24, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.