Skip to content

IntelliJ Git Merging with Jet Brains's git framwork

Amir Sagiv edited this page Jul 1, 2017 · 1 revision

Merging tutorial Following some conversations we had, it seems like some of us (including me), are still GIT-o-phobic. Even in the darkest of times (where we are forced to choose between keeping our changes, or override changes of others), there is always light at the end of the tunnel 🥇 many times fine-grained merging is needed (and not simply overriding or accepting entire files).

we pray to the git god to never see this message:

image

:-( Its ok, Follow:

  • commit your changes locally.

  • pull again from within intellij, in order to teach it about our conflicts: image

  • now you will see a list of pulled items, divided into files that were simply taken from the server, and files that have conflicts between our commit and the server (we need to take care of each of these) *for each file in the merged with conflicts group, select it, and then click VCS->Git->Resolve conflicts: image image

  • Click merge in the dialog box, you will be prompted to the conflict resolution tool: image

In that tool you will see on the left your version of the file, and on the right the server’s version. for each individual conflict within the files Clicking on a >> or << will decide which side will be included in the result file for that specific conflict (in some cases both sides can be included). Conflicts are devided into two, green conflicts are ones that do not contradict each other, and could be solved by simply adding both the changes from us and from the server (usually what is done to solve them). The middle result coloumn after accepting both changes:

image

On the other hand, red conflicts contradict each other, and to solve them you must first choose a side (>> or <<), and then manually change the code in the middle coloumn (result), to compensate the choice of a specific side. *Hit apply, and then commit again, with a message that says “merged conflicts”. *now you will be able to push and pull :) image

Clone this wiki locally