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

Re: how to undo a git merge?

From
Jakub Narebski <jnareb@gmail.com>
Date
Jul 11, 2008, 17:13 UTC
Message-ID
<m34p6we43y.fsf@localhost.localdomain>
In-Reply-To
<fa7d16350807110916x689e316fr6bae01f28e2e1acb@mail.gmail.com>
ff <ff@member.org> writes:
Show 9 quoted lines
> I have two git branches that stem from the same exact master branch.
> Many commits happened independently on these two branches overtime.
> Then, I inadvertently did a merge from one branch into another. The branch
> where I merged into now has mixed commits, and also a commit for the merge
> itself. I then had more commits added to the branch that I merged into.
> 
> Now I would like to revert the merge... what is the best way of doing that?
> I would like very much to use something like git-revert <merge_commit_id>
> But that does not seem to work.

If you have published history, then the only sane option is "git revert -m". If you haven't published history, you can try "git rebase --interactive".

-- 
Jakub Narebski
Poland
ShadeHawk on #git
Previous: Miklos VajnaNext: Miklos Vajna
Message 3 of 8 in “how to undo a git merge?”
  1. ffJul 11, 2008
  2. Miklos VajnaJul 11, 2008
  3. Jakub NarebskiJul 11, 2008
  4. Miklos VajnaJul 11, 2008
  5. ffJul 11, 2008
  6. Miklos VajnaJul 11, 2008
  7. Sverre RabbelierJul 11, 2008
  8. Jakub NarebskiJul 11, 2008

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.