47

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?

Lambart
  • 1,985
  • 2
  • 21
  • 37
  • 2
    4 years later and what is still really needed is a guided tour of the paradigm shitft from `svn` to `git`. At least we have stackoverflow. – Adam Jan 28 '16 at 11:33

3 Answers3

42

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

Thomas Ferris Nicolaisen
  • 5,036
  • 2
  • 30
  • 36
  • Thanks for your response. I don't think that will help me but in any case I do not see the "Synchronize" submenu. Perhaps because I am not working on a branch at this time, or perhaps because I am using an old version of Eclipse. Thanks for bringing that to my attention. I have no idea how I was led to the wrong download when I installed Eclipse on this dev machine just a few months ago. The failure of Eclipse to show a name instead of version number in "Help->About" seems stupid to me. I believed I was up to date. – Lambart Jun 29 '12 at 18:00
  • Wow, the Eclipse web site has become very confusing. It says a lot without communicating much useful information about what Juno is about. From reading the Eclipse development wiki I gather that only the latest 4.2 release of Juno (released this month) is actually recommended for general ues. I guess I was not as out of date as I thought. – Lambart Jun 29 '12 at 18:03
  • @Lambart I'll update my answer to provide some more details on how to use the Synchronize view. – Thomas Ferris Nicolaisen Jul 02 '12 at 14:16
  • 1
    thanks for your detailed and thoughtful update. Although I don't think anyone has answered my question yet (I'm afraid there is no answer), I would up-vote your answer if I had the reputation to do so. I do think I will try Juno soon but what you describe appears to be the functionality I'm already familiar with--I described it myself in the second paragraph of my question. Since you didn't mention it, I don't imagine it fixes the main problem (also mentioned in paragraph 2): Do you still have to (double-)click on each individual file, or can you easily step from one file to the next? – Lambart Jul 03 '12 at 23:05
  • If you are just looking for the keyboard shortcut to jump to next file, Ctrl+. works (and Shift+Ctrl+. for reverse). (Cmd+. on OSX). – Thomas Ferris Nicolaisen Jul 04 '12 at 08:11
  • Ah, that is happy news. That's how I've always done it--but it doesn't work here with Indigo + EGit. Since you say it works in Juno, I'm going to go ahead and upgrade. I'll come back and report my results. – Lambart Jul 04 '12 at 20:28
  • I haven't been able to work on this project for the past 3 months (new day job--mostly using vim for non-Java work), but am finally getting back to my own project, using a new laptop... so I finally installed Juno. And... you are right, everything works so much better than in Indigo! I'm very happy to finally be able to accept your answer. Thanks again for your help. – Lambart Dec 01 '12 at 22:25
  • 1
    P.S. Using custom keyboard shortcuts, I now have Ctrl+. set to "Select Next Change" when "Comparing in an Editor", and Ctrl+Shift+. set to "Next" when "In Windows". Now I can easily jump from change to change with Ctrl+period, and then when I get to the bottom of the file, I use Ctrl+Shift+period to jump to the next modified file. (I set up the opposite shortcuts with the "," key to go backwards) – Lambart Dec 01 '12 at 22:31
  • For some reason the Synchronize view wasn't showing me the destination branches. I had to use the Git Repositories view and right-click on the branch and select Synchronize with Workspace. This then opened up the Team Synchronizing perspective and all was good. – steinybot Jan 08 '15 at 02:06
  • 2
    I have gotten very used to using the Git Staging view now. I think it works better with the git concept of the index/staging area than Team Sync does. I don't like the screen layout on my small-screen laptop, and don't think I can use the keyboard to diff the next file, which was a big concern for me at first. But I have gotten used to grabbing the mouse. I changed my accepted answer, but very much appreciate your time and effort @ThomasFerrisNicolaisen -- and now I have the power to up-vote this fine answer, even though the other works better for me. – Lambart Feb 09 '15 at 19:01
  • @ThomasFerrisNicolaisen Is there any way to make the option `Include local uncommitted changes in comparison` to be checked by default ? – Vignesh Raja Jul 13 '18 at 06:35
  • @VigneshRaja I don't know. I haven't used Eclipse now in many years. – Thomas Ferris Nicolaisen Jul 13 '18 at 10:30
28

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)

Deepak Azad
  • 7,903
  • 2
  • 34
  • 49
  • 2
    Thanks for your response. No, I'd never heard of the Git Staging view. Unfortunately it uses the same compare editor, which will not allow me to move directly from one modified file to the next. I'm beginning to get the impression that it's Eclipse that's broken, not EGit. – Lambart Jun 29 '12 at 17:49
  • This link discusses a patch to EGit to fix exactly what is bothering me. But it's over 3 years old and I guess the patch was never accepted: http://git.661346.n2.nabble.com/EGIT-PATCH-0-3-Show-all-changes-files-in-the-same-compare-editor-td2136208.html – Lambart Jun 29 '12 at 17:50
  • 2
    It's Egit :-) But the tooling has been improving at a fair clip. – Deepak Azad Jun 30 '12 at 02:05
  • I wasn't sure how to capitalize the name at first, so I was careful to check before I wrote anything. If you look at Help->About Eclipse, click "Installation Details", go to the plug-ins tab, and sort by "Provider", you will see multiple entries listed as "Eclipse EGit". At least that's the case with Indigo. In any case, I would be happy to write it any way at all... if only it worked for me. :-) – Lambart Jul 03 '12 at 23:11
  • 2
    Oh I meant to say that it is EGit that is at fault here and not Eclipse in general :-) – Deepak Azad Jul 04 '12 at 01:07
  • Oh! I thought you were being picky about my writing. The reason I suspect it's Eclipse is that the compare editor is an Eclipse function, not one specific to EGit. And the compare editor isn't allowing me to advance to the next changed file when I've reached the end of a file and select "next change" again. But I suppose if EGit isn't setting up the compare editor properly then it could be at fault. – Lambart Jul 04 '12 at 01:31
  • 2
    My question got up-voted again so I came to review it and also the answers. For what it's worth, I have grown used to using the Git Staging view you recommended. I recently tried the Synchronize view again (not sure if that was before or after I updated to Eclipse Luna) but it still doesn't work as well as I remembered, and Git Staging just seems to work better. I think it still doesn't allow me to use the keyboard to easily jump to the diff of the next changed file, but I've gotten used to grabbing the mouse and double-clicking each file so I haven't tried that recently. – Lambart Feb 09 '15 at 18:58
  • 2
    btw, if for some reason you are seeing **"no repository selected"** in the **git staging view**, try to do these: 1. Go to "Git Staging" view an click "Link with Editor an Selection" 2. Go to "Git repositories" view, mark the needed repo and via contextmenu use "Copy Path to Clipboard" (may be "copy to clibboard" is not needed...) 3. The staging view was connected to the needed repo. [source](https://www.eclipse.org/forums/index.php?t=msg&th=222275&goto=699774msg_699774) – burcakulug Jun 09 '15 at 13:26
3

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.
Kt Mack
  • 381
  • 4
  • 17
  • 1
    Sounds useful! Personally, I found Eclipse so awful (beginning with the Luna rewrite), that in 2016 I finally switched to IntelliJ, and haven't looked back. – Lambart Jun 26 '19 at 17:09