Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you do merges using Git, Eclipse and Egit

I, like many others, love Eclipse as my ide of choice, and because of the way I work (moving about, different places, different projects) want to use Git for CVS.

There is a plugin for Git in Eclipse, Egit, which is now an official Eclipse project, and currently at version 0.7.1. As I've just started using it I'm interested in how others are using it, and what work arounds they are using. Currently Egit doesn't have support for merges, so these have to be done outside of Eclipse and then the workspace refreshed.

So, How do you do this task ? (and any other tasks that Egit doesn't do right now)

like image 855
PaulHurleyuk Avatar asked Mar 25 '10 22:03

PaulHurleyuk


People also ask

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.

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.

What is EGit in Eclipse?

EGit is an Eclipse Team provider for the Git version control system. Git is a distributed SCM, which means every developer has a full copy of all history of every revision of the code, making queries against the history very fast and versatile.

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.


2 Answers

Just for reference, EGIT does now support merges and uses the powerful diff interface within eclipse.

Once you have fetched the code and run a merge, if there are any conflicts they are highlighted in the project explorer with a red !, you can then right click on them and go to Team > Merge Tool, which is un-ghosted for conflicted files.

Once you have selected the code you wish to use (Either the workspace version with diff annotations in it or the HEAD version that caused the conflict) the diff window will open.

This shows your local code on the left and the conflicting code on the right, you can use the 'next difference' button to jump through all the conflicts, and the 'copy change from right to left' button to accept the remote version, or simply edit your local version in place.

Once you are happy with the changes save your file and add it, then commit the results and you should be done.

Please note I am in no way a master of git good practice, so please feel free to correct me if these are not the best operations to use, but it was an answer to the question "How do I do merges in eclipse with egit".

like image 73
MrCeeJ Avatar answered Oct 18 '22 08:10

MrCeeJ


When working with Eclipse, I only use egit to actually commit. Everything else I do simply via the command line. The command line in git (or any other VCS) is much more superior and the software was actually created with having the command line in mind, so it's just naturally that you can access really every single feature via the command line.

Everything else only uses the command line in the background and tries to emulate a different interface, native to the host application (here: Eclipse). But by doing that you can never reach the same power as by using the original tools.

However I think when egit develops more, it might be a good way to work with git; similar to how the subversion plugin for Eclipse works well with most functions. But in my situation, I don't use Eclipse for everything and using the command line is then a lot simpler than trying to get used to multiple different plugins and the command line.

like image 30
poke Avatar answered Oct 18 '22 10:10

poke