49

Ok. Simple things should be simple, so I hope it is. :)

I have changed a file, now I want to revert back to the latest version in the git repo because my changes are crap and I want to start fresh again changing the file.

As far as I am concerned you should do this:

git checkout -- <NAME OF FILE>

First question: How to do this inside eclipse with EGit? There is no checkout option under team. :( :( :(

Now let's suppose I have multiple files modified in multiple directors. How do I revert all of them to start fresh again?

robinst
  • 30,027
  • 10
  • 102
  • 108
JohnPristine
  • 3,485
  • 5
  • 30
  • 49
  • 1
    possible duplicate of [Eclipse git checkout (aka, revert)](http://stackoverflow.com/questions/1750997/eclipse-git-checkout-aka-revert) – robinst Feb 11 '13 at 23:32

3 Answers3

82

In my version "Replace With..." -> "HEAD Revision" seems to be doing just that...

It's not in the "Team" submenu, which is a bit confusing, I admit..

Also, this might help : Eclipse git checkout (aka, revert)

Community
  • 1
  • 1
phtrivier
  • 13,047
  • 6
  • 48
  • 79
14

Go to the "Synchronize" view (if you don't have it opened, it's in "Window" / "Show View"), populate the list in case it's not loaded, right click the file you want to revert and in the context menu select "Overwrite" to revert to the latest file in the Git server.

You can also check the changes you're going to discard before reverting by selecting "Open In Compare Editor" in the context menu.

Infinite Recursion
  • 6,511
  • 28
  • 39
  • 51
OMA
  • 3,442
  • 2
  • 32
  • 39
  • 2
    Yep, it works and it is logical ... just not as user friendly as in IntelliJ for example. – Stef Oct 31 '15 at 16:58
  • 2
    Too warped a solution IMO. Have to enable Sync view, then load the view, then select destination from a list - not as intuitive or less clicks as other responses and definitely not as nice as in IJ. – killjoy Jun 07 '17 at 13:04
8

You can get "Replace with Head Revision" from "Git Staging"

enter image description here

0xFK
  • 2,433
  • 32
  • 24