Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ git merge tool

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 ?

like image 373
Number945 Avatar asked Jan 28 '23 05:01

Number945


1 Answers

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.

like image 58
yole Avatar answered Feb 05 '23 18:02

yole