Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse and EGit: How to easily review changes to ALL modified files before committing to *local* repository

Tags:

git

eclipse

egit

I'm using Eclipse Indigo SR2 with the (built-in) EGit plugin v.1.3.0.201202151440-r and haven't been able to find any way to easily review all my changes before making a commit.

I used Eclipse with SVN for years, and this was always very easy to do. I would typically right-click on my project, select Team->Synchronize, double-click on the first changed file (in the Team Sync perspective), then hit Ctrl-. repeatedly to review all changes in one file, and then proceed to the next file, as I wrote a summary of my changes for the commit message.

But of course, git is very different from Subversion, and so my workflow must change. With EGit, "Team Sync" only appears to be useful for reviewing changes between my local files and the remote repository (i.e. before a push to the remote). I need a way to review changes since my last commit to my local repository. I generally don't even care to (re)review changes before a push to remote (and if I did, I'd prefer a simple equivalent of git log to see what commits I'm about to push).

If I right-click on my project and select Team->Commit, I am presented with a window that does almost everything I need to do (select files to stage, commit, write a commit message, amend a previous commit, etc.). What it doesn't allow me to do is quickly and easily review all my changes in a compare editor. I can't believe this capability doesn't exist! It seems I am required to double-click on each individual file, review the changes, close the compare editor, and double-click on the next file. That's ridiculous!

TL/DR - I am looking for a simple GUI equivalent (in Eclipse) to do what I am easily able to do from the command line using git vimdiff (where vimdiff is a git alias that uses vimdiff as the "difftool" to cycle through all modified files) followed by git commit (with perhaps a git add or two in between).

If no one has a good solution, I am curious about how others handle their commit workflow with EGit. I've been getting along fine committing from the command line (not that Eclipse is happy about that) but I can't believe that EGit is as near-useless as it seems to me. Perhaps my google-fu is not as strong as it once was?

like image 870
Lambart Avatar asked Jun 29 '12 02:06

Lambart


People also ask

How do I view modified files in Eclipse?

In the Eclipse Navigator view (or any Eclipse view that supports Team operations), right-click the file or folder and click Team > Show History.

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.


1 Answers

Says here that you can see the diffs between the working tree and any given reference. Perhaps you should try out the latest version (Juno) of Eclipse/EGit and see if it's gotten any better?

Update: I've tried this out in the latest Eclipse, and as far as I can see it works fine. Here's how:

In the moment of writing this, Eclipse Juno 4.2 is the version you should go for. On the download page, you can pick between several packages according to your needs. The 'Eclipse IDE for Java Developers' comes bundled with EGit, but you can also install EGit into any distribution using the Eclipse Marketplace (under the Help menu).

  • Once you've imported your project into Eclipse, make sure the project is "shared":

Right-click project -> Team -> Share Project.. -> Git

Now do the following:

  • Switch to the Team Synchronizing Perspective.
  • Click the little synchronize button in the Synchronize View.
  • Choose Git
  • Pick a suitable branch to sync against, like refs/remotes/origin/master
  • Make sure to check the "Include local uncommitted changes in comparison" box
  • Click Finish

Now, change some files and watch them appear in the Synchronize View. Double-click the changed files to see the diff (like in the screenshot below).

Screenshot of Eclipse Juno - EGit Synchronize View

like image 120
Thomas Ferris Nicolaisen Avatar answered Oct 20 '22 21:10

Thomas Ferris Nicolaisen