Search code examples
eclipseegit

Trying to understand the process of Resolving Merge Conflicts with Eclipse/egit


On the project that I am working on now, we are doing mostly Java development using Eclipse, egit, and also Bitbucket.

Because multiple developers are working on the same file simultaneously, I am constantly (basically every time I do a commit/PR) getting merge conflicts, which I haven't really haven't had to deal with before, so, honestly, I am struggling with handling and "resolving" the conflicts.

When I get a merge conflict, Bitbucket says to:

Checkout the source branch and merge in the changes from the target branch. Resolve conflicts.

git checkout dev/55039
git pull origin rel/7.1

After I run those 2 git commands, in Eclipse, I typically see several files appear in Staged Changes and usually 1 or 2 files in Unstaged Changes.

If I click on a file Unstaged Changes, I get the pane with a file from my branch and the other pane shows the conflicting file from another PR.

Parts of the files are marked in different colors (red, blue, gray), and I think those are marking blocks of code that are in different states of conflict vs. non-conflict?

I think that my problem is that I don't understand what the goal is. I mean I know I need to resolve/remove the conflicts but I am having a hard time understanding what I need to do to accomplish that, so I was wondering if someone could point me to a good source to get an understanding about that, specifically with Eclipse and egit?

For example, with the 2 panes, and say there is a big chunk of lines in the right pane that is blue. Should I copy those lines from the right pane to the left pane? Or not?

What is the "end state" that I want to get to in order to "resolve" the conflict?


Solution

  • The documentation on how to merge in Eclipse can be found in Help > Help Contents: EGit Documentation > EGit User Guide > Tasks > Merging

    If you run Git commands outside of Eclipse, make sure to do a refresh afterwards (e.g. in the Git Staging view, by hitting the Refresh (F5) button). But better learn what these commands mean and how to do these commands in Eclipse.