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

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


Are you aware of the 'Git Staging' view. It keeps track of all the files that have changed and you can review the changes any time. (This can be a bit better than using the commit dialog)

An alternative is to commit all changes without reviewing, and then use the history view to compare two commits (Simply select the last top most commits, right click and select 'Compare with each other'). This way you do not have to keep double clicking individual files. If you need to change something you can always 'Amend' the last commit. (I usually follow this approach)


I am writing this as of Eclipse Oxygen, but it should apply to other versions as well.

  1. Option 1 with team synchronizing view: right click the project > Compare with > Commit. You can choose your latest commit here, even if you haven't pushed it to repository.
  2. Option 2 with diff view: If you want to see the "diff" version without committing, you can achieve this by right clicking your project > team > stashes > Stash Changes > check Include untracked files. This will save all of your changes to a stash. Then you will right click project > team > stashes > select stash you saved. You click the green arrow at the top right to re-apply all of your changes you stashed back to your code. In the same stash window, you will see a "Diff" tab at the bottom right. Clicking on the diff tab will show your changes in the red/green highlighted diff style. I wish there was a way to generate a diff view without stashing, but this is the only work-around I have found.

Tags:

Eclipse

Git

Egit