Dims
Dims

Reputation: 51239

Merge diff corrupts code in IntelliJ

I am trying to merge some revisions in IntelliJ and it showed a diff for me. Unfortunately, diff does not notice identical code and inserts strange text like

<<<<<<<HEAD

into result.

Here is screenshot. As you see, code is identical, but it is colored somewhere red and somewhere blue.

enter image description here

How to restore normal merge functionality?

Upvotes: 2

Views: 194

Answers (1)

Flowers4Life
Flowers4Life

Reputation: 151

What you have here is a merge conflict. You can read here for more information about how IntelliJ handles conflicts under Conflict Resolution Tool here: https://www.jetbrains.com/help/idea/2016.2/resolving-conflicts.html

The "strange text" is injected into the conflicted file by Git, so you would see these even outside the IntelliJ merge tool. If the local and remote content differs, a line of = signs will be the divider between your local version and the remote version. In this case since both revisions are equal, you simply have a single line conflict with the same content from both sources.

Essentially, you need to choose which revision of the code to use by selecting the chevrons & X's on either side of the window panel of your screenshot. There is also a handy 'merge non-conflicting changes' button that makes reviewing the actual conflicts much easier.

Upvotes: 1

Related Questions