Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve conflicts in EGit

Tags:

git

eclipse

egit

I am using EGit on Eclipse v4.3 (Kepler). I want to commit and push my changes. I do a pull first and one file is conflicting. After manually resolving the conflict (local and remote are the same now), I am still running into problems.

Here are the error messages for each action:

Push to upstream

master: master [rejected - non-fast-forward]

Pull

Cannot pull into a repository with state: MERGING_RESOLVED

Mark as merged

Failed to add resource to index Failed to add resource to index Exception caught during execution of add command

Hard reset

An internal error occurred during: "Resetting to refs/heads/master". Exception caught during execution of reset command. {0}

How can I remove the conflict and push my changes? What am I doing wrong?

like image 643
Sionnach733 Avatar asked Feb 04 '14 17:02

Sionnach733


1 Answers

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.

like image 130
dan carter Avatar answered Sep 19 '22 10:09

dan carter