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

RE: Undoing merges

From
Richard <richard@webdezign.co.uk>
Date
Dec 14, 2009, 11:45 UTC
Message-ID
<8440EA2C12E50645A68C4AA98871665131D9AC@SERVER.webdezign.local>
In-Reply-To
<vpqpr6pqrvq.fsf@bauges.imag.fr>
Hi again Matt,
Thanks for the reply.
Show 11 quoted lines
> > Hi git list,
> >
> > I'm trying to find out how to undo a merge.
> 
> When sitting on a merge commit,
> 
>   git reset --merge HEAD^
> 
> will undo this merge commit (i.e. pretend the merge has never
> occurred, at least in your branch). Don't do that if you already
> published this merge commit.
The problem that I'm far past the merge commit.
Show 7 quoted lines
> > I know that my branches are independent and that I can just carry on
> > working on them and merge again later, but I'm just trying to keep
> > my revision graph tidier. Should I even be undoing merges?
> 
> If it's about cleaning up your history, "git rebase" is your friend,
> too (with the same limitation: don't do that on published history). By
> default, it does some kind of history flattening.

I had a look at the git-rebase man page and it showed to remove a commit from the middle of a range of commits. I think as I am on longer on the merge commit and cannot use "git reset --merge HEAD^", I can rebase all the commits from the commit just after the merge onto the commit just before the merge and that will remove the merge. Unfortunately I didn't get a change to try that out so I don't know whether it will work or not.

Richard
Previous: Matthieu Moy
Message 3 of 3 in “Undoing merges”
  1. RichardDec 8, 2009
  2. Matthieu MoyDec 8, 2009
  3. RichardDec 14, 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.