Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I fix "Cannot pull into a repository with state: MERGING" in EGit?

Tags:

git

eclipse

My team recently moved to Git, and for the second time today, Git has erred out on a single line of code that I myself changed and already committed to my local, on a file that was last edited by myself. This is the error message it gives me:

Cannot pull into a repository with state: MERGING" org.eclipse.jgit.errors.WrongRepositoryStateException  Cannot pull into a repository with state: MERGING     Cannot pull into a repository with state: MERGING 

I cannot pull or push to the remove server. How do I fix this?

Actually, better question, how do I prevent this?

like image 618
NobleUplift Avatar asked Jun 24 '15 21:06

NobleUplift


People also ask

Why is the merge tool disabled in eclipse for a EGIT managed project?

Make sure you have merged with desired branch, then if your merge results in conflicts, your project will enter Conflicts mode, and the Merge Tool will be enabled.

How do you merge in EGIT?

Your task is to merge a different branch into that branch. After doing a "fetch" to ensure that your branch metadata is up to date, right-click on the repository and select "Merge...". Select the branch you want to merge into your current branch. After that completes, inspect the "Git Staging" view.


2 Answers

This is happening because you are in the middle of a merge. Either complete the merge by resolving all conflicts and adding the appropriate files to the index, or abort the merge with git merge --abort. Note that if you do abort the merge, you will most likely get conflicts when you do your git pull, as I assume your previous pull caused conflicts (which is why you were left in the middle of a merge).

like image 115
David Deutsch Avatar answered Sep 24 '22 02:09

David Deutsch


The problem here is remote repository files have been changed(i.e. someone else have changed and pushed the file to the repository which you changed in your local copy) and now you also edited the same.So when you try to push the file it throws an error.
You have to merge the file and then commit the changes and push.

Right click on your project -> Team ->Merge

When you do this it will ask for which branch to merge. Select the branch and proceed to merge.

case 1: If there is no conflict, then merge process will be completed. You can commit and push now.

case 2: In case if there is a conflict egit will show the error message as Conflict and all those files having conflict will be marked with a red icon over the file name on your project explorer.

Right click the files with conflict-> Team -> Merge Tool

This will open the comparision window.Check and merge the changes you want. Once you completed merging

Right click the files with conflict-> Team -> Add to index Commit the changes and Push

Note : You have to commit all your staged files before this merging process.
And to answer your question
"Actually, better question, how do I prevent this?"
This is not an issue, it happens when multiple users are working in a single repository.Whenever you tend to push, before pushing try pulling from the remote repository.When you try to pull egit will say if there is any pending changes or conflicts in remote repository and you solve the conflicts and push.

like image 44
Vijay R. Avatar answered Sep 20 '22 02:09

Vijay R.