Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do an "ours" merge using the Eclipse git merge tool?

Tags:

eclipse

egit

I'm trying to do a merge where I have conflicts and one file has diverged massively. The eclipse git merge tool is great for small changes, but one of my files is large and has hundreds of explicitly marked conflicting sections. I can't for the life of me find an easy way to just do a merge using the "ours" strategy of just using my version and abandoning the remote version.

On Linux or Mac it would be easy for me to just do it from the command line, but I'm on a corporate Windows computer and don't have command-line git. I even tried the workaround of doing "replace with" -> "Head revision" from the file's context menu in the package explorer, but that action is disabled since the repository is in merge conflict mode. This would be an ok solution, but it would still be preferable to have a clear way of applying "ours" or "theirs" strategies to entire files from the merge tool.

I had to resort to a hard reset, making a copy of my file, doing the merge, and then replacing the merged version with my clean copy. Am I missing a much easier way of doing this?

like image 872
mightybyte Avatar asked Jul 26 '12 17:07

mightybyte


People also ask

How do I merge in Eclipse?

To start merging click 'Team>Merge...' menu item of the resource pop-up menu, 'Merge...' menu item of the SVN main menu group or on the 'Merge...' button on the 'SVN Toolbar'. The Merge Dialog will appear and to perform operation user should follow its instructions and fill needed properties.

How do I merge codes from one branch to another in eclipse?

To do this, select the project and choose Replace With > Another Branch or Version from the context menu. Then select the branch to replace with. Select the project and choose Team > Merge. Enter the branch or version which contains the changes you want to merge.

How do I merge conflicts in eclipse?

To resolve the conflicts in the Eclipse Compare Editor, right-click the conflicted file and click Open in compare editor. In the Compare Editor, you can use the Copy all nonconflicting changes from right to left button to reduce the number of conflicts that you must review and resolve yourself.

How does git merge tool work?

The git mergetool helps the developer to resolve conflicts in an efficient way. It provides a GUI where you can look at versions from your current branch, remote branch, common ancestor and final merged version, all in one window, which we will see going further into the article.


2 Answers

In the editor of the merge tool, you can edit the left section.

After clicking on Merge Tool, select the "HEAD" option in the dialog that appears, then the left section will contain the same content as HEAD.

So when the left section is already good, just make a small modification, undo it and then save. The modification is necessary because save is not available from the beginning.

like image 175
robinst Avatar answered Oct 23 '22 10:10

robinst


There is now an entry "Replace With" that allows you to select "Ours" or "Theirs" in the context menu for files in the Git Staging view.

like image 30
jmiserez Avatar answered Oct 23 '22 08:10

jmiserez