DigitalJoel

2009/09/11

Recovering a lost file in Eclipse

Filed under: eclipse — Tags: — digitaljoel @ 8:46 pm

The other day I was working on my project. I had cygwin open and copied a file to another so I could use it as a template. Unfortunately, I typed the wrong name and overwrote an existing file that I had local modifications in. Because of the local modifications, couldn’t just get it back from source control. So, how could I the contents of the file back?

Since the file was in eclipse, I refreshed the project, then right clicked on the file. Select “Compare To” and “Local History”. I selected a time previous to when I had copied the file over my existing file. The previous revision is on the right side of the comparison, and my new, incorrect stuff is on the left. I was then able to select all on the right and copy it into where it ought to be.

Since that time I have learned that you can right click the file in the Package Explorer, select Replace With, and Local History or Previous from Local History and you can select a previous version and replace the file rather than having to select the contents and paste.

This also works if you delete a file, even if you delete it within eclipse. Simply create a new file of the same name, refresh the project to get the new file, and compare to local history.

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.