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 19, 2008, 00:46 UTC
Message-ID
<alpine.LFD.2.00.0812181637140.14014@localhost.localdomain>
In-Reply-To
<1229646948.5770.33.camel@rotwang.fnordora.org>
On Thu, 18 Dec 2008, Alan wrote:
> 
> So what is the recommended way to undo mistaken merges caught after the
> fact that will not fubar later merges?

Oh, I suspect reverting is the right thing, it's just that then you need to remember to revert the revert if you intend to merge that branch again later.

So reverting a merge isn't _wrong_ per se. It's just that you need to be aware of the consequences, and if it becomes a common situation, you have a problem in your usage patterns.

Btw, even with non-merge commits, "revert" can have interesting effects exactly because it doesn't change history. For example, let's say that you had a history like this, with two branches:

	--> a --> b --> c --> d
	      |
	      +-> e --> !a

where the second branch reverts 'a', but the first one does not. What happens when you merge the two branches? Is the revert sticky? In this case, yes, a merge will cause the revert to stick. But what happens if you had

	--> a --> b --> c --> d
	      |
	      +-> e --> f --> !e

and 'b' and 'e' were the same patch (just applied in two different branches), and '!e' reverts that patch in the second branch. What happens to 'b' when you merge? Would you expect for 'b' to go away, since the revert undid the same data in the second branch?

In that second case, the revert of 'e' will basically make git act as if 'e' didn't happen at all in the second branch, and so when you merge them, 'b' _will_ exist in the end result, so now the revert didn't "take".

All of this is very self-consistent (it's a very direct result of how merges work and how revert works), but I'm just bringing these things up as examples of how 'revert' is not a totally trivial matter. You'll always find cases where you might have wished that it had acted differently when you merge things.

			Linus
Previous: AlanNext: Nanako Shiraishi
Message 6 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.