Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Evil merges in git?

Tags:

"man gitglossary" contains this definition of an evil merge:

An evil merge is a merge that introduces changes that do not appear in any parent.

I am not sure I understand the point the authors are trying to get at. Why is it evil ?

like image 588
krosenvold Avatar asked Sep 22 '09 18:09

krosenvold


People also ask

Is Git merge destructive?

Git merging is a great way to go because it is considered a non-destructive operation. This is because the existing branches are not changed in any way. It also helps you avoid the potential pitfalls that come with rebasing, which we will take a look at below.

What are the types of merge in Git?

Git merging combines sequences of commits into one unified history of commits. There are two main ways Git will merge: Fast Forward and Three way. Git can automatically merge commits unless there are changes that conflict in both commit sequences.

What is the best Git merge strategy?

The most commonly used strategies are Fast Forward Merge and Recursive Merge. In this most commonly used merge strategy, history is just one straight line. When you create a branch, make some commits in that branch, the time you're ready to merge, there is no new merge on the master.

How does Git detect merge conflicts?

For simple text files, Git uses an approach known as the longest common subsequence algorithm to perform merges and to detect merge conflicts. In its simplest form, Git find the longest set of lines in common between your changed file and the common ancestor.


1 Answers

Because it's putting things in the code that no one ever asked to be there. As if you had this code:

$foo = bar; $baz = qxx; 

and this change:

$foo = bar; $foo++; $baz = qxx; 

got merged with this change:

$foo = bar; $foo--; $baz = qxx; 

in a fashion that somehow produced:

$foo = bar; $foo++; $foo--; --$baz; $baz = qxx; 

Clearly, this is evil.

I would guess that it's of enough concern to be in man gitglossary because the more involved your merging algorithms are, the more likely it is that they will produce such a thing.

like image 167
chaos Avatar answered Sep 22 '22 14:09

chaos