views:

370

answers:

3

Is it possible to do the equivalent of git checkout from within Eclipse using the EGit plugin?

I have a file that's been modified. I want to discards the changes and revert the file back to what's in the source repository. In Subversion this is called revert. In git the equivalent is checkout.

I can't find any menu item under Team that looks like checkout or revert. I'm using EGit 0.6.0.

+1  A: 

You can achieve this by doing a (hard) reset. On the project's context menu, select Team > Reset to..., choose "HEAD" and "Hard" as reset type.

Please note that doing this you will lose the changesof ALL files. AFAIK there is no way (yet) to revert just a single file.

simon
I just found out the hard way that commit also does the same thing - commits ALL files instead of just the selected file.
Steve Kuo
Right, but at least you _can_ deselect files in the commit dialog...Btw: I filed a bug for the reset https://bugs.eclipse.org/bugs/show_bug.cgi?id=295423
simon
Git support in Eclipse is really inferior to CVS and SVN because of this! CVS's "Replace with latest from HEAD" functionality is really important to me.
kosoant
A: 

The functionality is actually in there, but it may be non-obvious:

  • Make sure quickdiff is enabled with a git revision and the quickdiff baseline is HEAD (this is the default).
  • Open the file you want to revert.
  • Select everything (Ctrl-A)
  • Right-Click in the quickdiff bar
  • Select "Revert selection"
  • Save

btw, revert in git lingo means create a new commit to revert an earlier commit.

robinr