Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
241 views
in Technique[技术] by (71.8m points)

git - How to revert changes due to a merge with Eclipse and EGit

I am using Eclipse Mars.1 (4.5.1) with EGit 4.1.0.

After a merge from a branch into master, I cannot figure out how to tell EGit to resolve a conflict by simply keeping the version that was in master before the merge, ignoring anything that came into that file as a result of the merge.

This is what I do. My Java projects all point to master. No uncommitted changes in any project.

In Package Explorer view I right-click a project, click Team, Merge.

In the "Merge 'master'" dialog that pops up I select a branch (under "Local"), I leave the "Merge options" on "Commit" and the "Fast forward options" on "If a fast-forward, only update the branch pointer".

I click "Merge". The "Merge Result" dialog pops up and says "Result Conflicting". Fair enough, I was expecting conflicts and I'm going to resolve them manually one by one.

Now, my problem is that for some of the files in conflict the way I want to resolve the conflict is simply to reject any change to that file resulting from the merge; just keep that file as it was before I did the merge. This should be trivial to do (at least in SVN it was), but I cannot see anywhere in Eclipse how to do that. The merge has filled the file with the "<<<<<<" conflict markers and I just don't see what needs to be done to revert those changes only in that file so that that file simply becomes unchanged with respect to master, which is where all the projects are pointed.

If I right-click on the file in the Synchronize view and select "Overwrite", I am asked if I "want to overwrite local changes". That's exactly what I want, I want the file to have no local changes, so I click Yes. But the result is that the file gets deleted locally, although it exists both in master and in the branch. It disappears from Package Explorer, and since I also had it open in the editor, that editor tab closes away. That's not what I meant by "overwrite local changes" and I don't understand why it happens.

If instead of "Overwrite" I select "Mark as merged" (although the conflict markers are still there), the file is no longer shown as in conflict, but it still has all the conflict markers in it and of course is still shown as changed, while I want it to be unchanged with respect to master.

And if instead I resolve all the conflicts in the other files and I want to commit all the files except the problematic one - so that that one will stay unchanged - when the commit dialog shows up and lists all the files to be committed, each with a checkbox, and I click on the checkbox of the problematic file to exclude it from the commit, the checkbox doesn't get unchecked, and this goes for any of the other files; the checkboxes don't look disabled, but they don't respond to the click.

What am I missing ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

As of now checkout ours/theirs is available on conflicting files in the EGit staging view only


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...