NobleUplift
NobleUplift

Reputation: 6005

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

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?

Upvotes: 34

Views: 103270

Answers (7)

david_lid
david_lid

Reputation: 11

Half-way through a pull my Eclipse died. Subsequently I was left in this state.

To resolve, I deleted the index.lock file in the .git folder. I was only then able to do the git merge --abort as suggested elsewhere.

Upvotes: 1

prash
prash

Reputation: 1016

This is how I resolved -

1) Right click on project -> Team -> Reset -> [Reset popup will open]
2) By Default Local Repo will be selected -
Reset to: refs/head/master
Reset Type: Mixed (HEAD and index updated)
3) Click on Reset
4) Right click on project -> Team -> Git Pull
5) Right click on project -> Team -> Push to upstream

Upvotes: 13

Dave
Dave

Reputation: 59

I met this kind problem by using eGit today. The solution is that you can choose the conflicting file and then Revert commit. Then you can resolve the conflicting file and add to index, commit and push

Upvotes: 0

RoutesMaps.com
RoutesMaps.com

Reputation: 1690

  1. I tried for openshift project problem recommended before: git merge --abort.
  2. I have become to problem “cannot pull into a repository with state: merging_resolved”. Resolved it by: git reset --hard See: "cannot pull into a repository with state: merging_resolved"
  3. Than made: git pull
  4. git commit
  5. To quit VIM editor I have used:<Esc key>:q<Enter key>

    6. git push

Success!

Upvotes: 3

Sumit
Sumit

Reputation: 1122

Right click on conflict file/package and select add to index and commit

Upvotes: 1

David Deutsch
David Deutsch

Reputation: 19015

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).

Upvotes: 15

Vijay R.
Vijay R.

Reputation: 482

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.

Upvotes: 7

Related Questions