How to resolve conflicts in EGit How to resolve conflicts in EGit git git

How to resolve conflicts in EGit


Are you using the Team Synchronise view? If so that's the problem. Conflict resolution in the Team Synchronise view doesn't work with EGit. Instead you need to use the Git Repository view.

Open the Git perspective. In the Git Repository view, go to on BranchesLocalmaster and right click → Merge...

It should auto select Remote Trackingorigin/master. Press Merge.

It should show result:conflict.

Open the conflicting files. They should have an old sk000l >>>> ===== <<<< style merge conflict in the files. Edit the file to resolve the conflict, and save.

Now in the 'Git Staging' view, it should show the changed file in 'Unstaged Changes'. Right click and 'Add to Index'

Enter image description here

Repeat for any remaining files.

Now from the 'git staging' view, commit and push. As Git/Eclipse now knows that you have merged the remote origin changes into your master, you should avoid the non-fast-forward error.


I also find it confusing to resolve merge conflicts in EGit. When I am ready to commit some changes to a shared repository, the steps I have learned are as follows:

  1. Right click on the project and choose Team: Commit....
  2. Review my changes to check that I'm not committing any changes I made accidentally or unrelated changes that I forgot about. Write up the commit message while I'm reviewing the changes.
  3. I'm optimistic, so I start by clicking the Commit and Push button. If no one else has pushed any changes, I'm done. If someone has, then the commit succeeds, and the push gets rejected.
  4. Right click on the project and choose Team: Pull. If there are no conflicts, then choose Team: Push to Upstream and I'm done.
  5. If there are conflicts, look through the package explorer to see which files are conflicted. Right click on each conflicted file, and choose Team: Merge Tool. It will show all the changes in both versions of the file, with any conflicts shown in red. Click on the button to merge all non-conflict changes, then edit any red sections manually. There's also a button to show a three way merge that includes the common ancestor.
  6. Save the changes to the file. If you want, you can compare it to HEAD to see what changes you are making on top of the changes you just pulled.
  7. Right click on the file and choose Team: Add to Index to tell EGit that you've finished merging that file. To me, this is the least intuitive step, but the git command line also uses the add command to show that a merge is finished.
  8. Repeat for any other conflicted files.
  9. When all the files are merged, right click on the project and choose Team: Rebase: Continue Rebase. If there are more conflicted commits, go back to dealing with conflicts.
  10. When the rebase is complete, run your tests to see that the rebase didn't break anything.
  11. Right click on the project and choose Team: Push to Upstream.


This guide was helpful for mehttp://wiki.eclipse.org/EGit/User_Guide#Resolving_a_merge_conflict.

UPDATEDJust a note on that about my procedure, this is how I proceed:

  1. Commit My change
  2. Fetch (Syncrhonize workspace)
  3. Pull
  4. Manage Conflicts with Merge Tool (Team->Merge Tool) and Save
  5. Add each file to stage (Team -> Add to index)
  6. Now the Commit Message in the Stage window is prefilled with "Merged XXX". You can leave as it is or change the commit message
  7. Commit and Push

It is dangerous in some cases but it is very usefull to avoid to use external tool like Git Extension or Source Tree