IntelliJ git merge tool
Asked Answered
O

2

5

Now when I try to resolve merge conflicts through IntelliJ , I find these colours - Green , Blue , Grey and Red as shown in image below :

enter image description here

It seems that areas marked with Green , Blue and Grey are automatically handled by Git merge if we do git merge by terminal. Only thing where Git needs our opinion is in the areas marked with red.

Then why has IntelliJ merge tool complicated our choice of selection ? It should have only shown Red and should not ask about Green , Blue and grey ?

Does that mean we cannot rely on Git algorithm for resolution of Grey , Green and Blue areas ? In my whole experience with Git till now, I have seen people blindly trusting Git merge and only tried to resolve the conflicted parts shown by it - that is the red areas ?

Opium answered 25/4, 2018 at 19:6 Comment(5)
jetbrains.com/help/idea/file-status-highlights.html The tool in intellij shows more than just conflicts.Auriculate
@AdamS , but the merge tool actually give us option to select or deselect these areas apart from red which should not be the case . Why mess around ? is it a merge tool to make merging more confusing ?Opium
If you are working on a team of developers and have to solve a merge conflict, sometimes you have to change your code to make it compatible with the changes the other developers made while you were working on your task. It is not true that in all cases you will want your added and removed code to be pushed- sometimes you want to edit that code in order to make it work with the changes you make after resolving the merge conflict. For this reason, the tool makes it easy for you to view all recent changes.Auriculate
@AdamS , what do you mean by changing code ? Just selecting and deselecting hunks ? (In this merge tool, we cannot edit hunks ) If this was the intention , the merge tool should have given option to edit those hunks too rather than us going again in code files and editing them there.Opium
This merge tool does have the option of editing the result of the merge (the middle pane). Editing the original text on either side would cause nothing but confusion.Gosselin
G
9

IntelliJ IDEA's merge tool has the "Apply non-conflicting changes" button in the toolbar, which will automatically merge in all the non-red hunks. This is basically the equivalent of only looking at conflicts in the results of the Git command-line merge.

The reason why IntelliJ IDEA does not do that automatically when the dialog is opened is not because Git's algorithm cannot be trusted, but because showing all changed hunks makes it easier to understand the context of the changes which led to a conflict, and to better understand how to resolve the conflict.

And IntelliJ IDEA does have the possibility to perform arbitrary edits to the merge result - the middle pane is fully editable.

Gosselin answered 26/4, 2018 at 5:58 Comment(0)
K
0

It seems that Rubymine/Intellij doesn't care about git diff3 config.

git config --global merge.conflictstyle diff3

Yes automatic conflicts resolution button is neat, but when I want precision and simplicity I just open a text editor. The IDE is very confusing when merging because it shows more conflicts than there are.

Keeshakeeshond answered 28/7, 2021 at 18:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.