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

Re: Odd merge behaviour involving reverts

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Dec 18, 2008, 23:58 UTC
Message-ID
<alpine.LFD.2.00.0812181534310.14014@localhost.localdomain>
In-Reply-To
<1229642734.5770.25.camel@rotwang.fnordora.org>
On Thu, 18 Dec 2008, Alan wrote:
> 
> What am i doing wrong here?
Reverting a merge is your problem.

You can do it, but you seem to have done it without understanding what it causes.

A revert of a merge becomes a regular commit that just undoes everything that the merge did in your branch. When you then do the next merge, you'll do that merge with that in mind, so now git will essentially consider the previous merge to be the base line, but your revert undid everything that that one brought in, so the new merge will really only contain the new stuff from the branch you are merging.

So if a merge causes problems, you generally should either undo it _entirely_ (ie do a 'git reset --hard ORIG_HEAD'), not revert it.

Of course, if you had already made the merged state public, or done development on top of it, you can't really do that. In which case a revert works, but if you want it back, you should revert the revert, not merge the branch again - because what you merged last time you threw away, and won't be applied again.

		Linus
Previous: AlanNext: Alan
Message 2 of 17 in “Odd merge behaviour involving reverts”
  1. AlanDec 18, 2008
  2. Linus TorvaldsDec 18, 2008
  3. AlanDec 19, 2008
  4. Linus TorvaldsDec 19, 2008
  5. AlanDec 19, 2008
  6. Linus TorvaldsDec 19, 2008
  7. Nanako ShiraishiDec 19, 2008
  8. Linus TorvaldsDec 19, 2008
  9. Jay SoffianDec 19, 2008
  10. Linus TorvaldsDec 19, 2008
  11. Daniel BarkalowDec 19, 2008
  12. Junio C HamanoDec 19, 2008
  13. Nanako ShiraishiDec 19, 2008
  14. Junio C HamanoDec 19, 2008
  15. Nanako ShiraishiDec 19, 2008
  16. Junio C HamanoDec 19, 2008
  17. Boyd Stephen Smith Jr.Dec 19, 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.