git 如何修复 EGit 中的“无法拉入状态为合并的存储库”?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31037250/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I fix "Cannot pull into a repository with state: MERGING" in EGit?
提问by NobleUplift
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:
我的团队最近搬到了 Git,今天第二次,Git 在我自己更改并已经提交给我本地的单行代码上出错了,这是我最后一次编辑的文件。这是它给我的错误信息:
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?
实际上,更好的问题是,我该如何防止这种情况发生?
采纳答案by Vijay R.
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
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.
情况1:如果没有冲突,则合并过程将完成。您现在可以提交和推送。
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.
情况 2:如果存在冲突,egit 会将错误消息显示为 Conflict,并且所有存在冲突的文件都将在项目资源管理器的文件名上方标有红色图标。
Right click the files with conflict-> Team -> Merge Tool
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 indexCommit the changes and Push
Right click the files with conflict-> Team -> Add to indexCommit 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.
注意:您必须在此合并过程之前提交所有暂存文件。
并回答您的问题
“实际上,更好的问题是,我如何防止这种情况发生?”
这不是问题,当多个用户在单个存储库中工作时会发生这种情况。无论何时您倾向于推送,在推送之前尝试从远程存储库中拉取。当您尝试拉取 egit 时,会说明是否有任何未决的更改或冲突远程存储库,您解决冲突并推送。
回答by David Deutsch
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).
发生这种情况是因为您正处于合并过程中。通过解决所有冲突并将适当的文件添加到索引来完成合并,或者使用git merge --abort
. 请注意,如果您确实中止了合并,则很可能会在您执行您的git pull
.
回答by prash
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
回答by RoutesMaps.com
- I tried for openshift project problem recommended before: git merge --abort.
- 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"
- Than made: git pull
- git commit
- To quit VIM editor I have used:
<Esc key>:q<Enter key>
6. git push
- 我尝试了之前推荐的 openshift 项目问题:git merge --abort。
- 我遇到了“无法拉入具有状态的存储库:merging_resolved”的问题。解决方法: git reset --hard 参见:“无法拉入状态为 merging_resolved 的存储库”
- 比制造:git pull
- 提交
- 要退出 VIM 编辑器,我使用过:
<Esc key>:q<Enter key>
6. 推送
Success!
成功!
回答by david_lid
Half-way through a pull my Eclipse died. Subsequently I was left in this state.
中途一拉我的Eclipse就死了。后来我就留在了这种状态。
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.
为了解决这个问题,我删除了 .git 文件夹中的 index.lock 文件。那时我才能够git merge --abort
按照其他地方的建议进行操作。
回答by Sumit
Right click on conflict file/package and select add to index and commit
右键单击冲突文件/包并选择添加到索引并提交
回答by david_pang
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
我今天通过使用 eGit 遇到了这种问题。解决方案是您可以选择冲突的文件,然后恢复提交。然后你可以解决冲突的文件并添加到索引、提交和推送