Brian Laframboise
Brian Laframboise

Reputation: 5514

How to undelete a file with Subversive?

Please note: This is a question about the Eclipse plugin Subversive, and not about Subversion itself. Please do not change the title to be about 'Subversion'.

So I deleted a file that I really shouldn't have.

I've found various approaches to restoring the file outside of Eclipse/Subversive, but I was wondering if there was a best/easiest-to-use/history-restoring way to restore the file using the Subversive tool.

Upvotes: 19

Views: 12477

Answers (7)

fustaki
fustaki

Reputation: 1614

I had a similar issue, I deleted a set of files related to a feature that after a couple of months I want to recover.

The most straightforward solution in my case was to check out in a separate directory the whole project as it was before the file were deleted.

To do this from the Eclipse Repository View go to your project, right click "Check Out As...", in the modal window write the destination folder, select a suitable date of the past in which the deleted file existed (weird, my plugin does not give the possibility to choose a given revision..) and check out.

Now you can easily search, find and copy-paste the files you want to recover.

Upvotes: 0

brunobg
brunobg

Reputation: 846

Easier: try to commit, Eclipse will show you the dialog with the changed files, click on the one you want to delete with the right button and pick "Revert".

Upvotes: 0

marcel
marcel

Reputation: 412

Just "Show History" on the folder, file was existing in. Then click through the history and find the lost file.

Upvotes: 2

Peter Hilton
Peter Hilton

Reputation: 17344

  1. Select the folder in the project that contained the deleted files.
  2. Right click, select Team > Merge...
  3. On the URL tab, set the URL to the server URL for the same folder.
  4. In Revisions, select Revisions and enter a range that includes the deletion, e.g. 1000-1001, or use the Browse button to select them.
  5. In Revisions, enable Reversed merge
  6. Click Preview and check that it shows an Added entry for the files you plan to restore.
  7. Click OK - Eclipse switches to SVN Merge in the Synchronize view.
  8. In the Synchronize view, right click the files you want and select Accept
  9. In the Synchronize view, use the Synchronize SVN icon to switch from SVN Merge to SVN, where you can see the restored file as an outgoing change.

Upvotes: 17

dreeves
dreeves

Reputation: 26952

I guess you're hoping to not resort to the command line but in case it's useful as a last resort, see this question for how to do it from the command line: What's a simple way to undelete a file in subversion?

Upvotes: 0

Frank
Frank

Reputation: 66224

If you have already submitted the remove then it's now time to roll back to the earlier version. In Subversion you do that with "svn merge", where you merge "backwards" from the current to the previous version.

Say you did this:

$ svn rm file.txt
$ svn ci -m "don't need that file"
Committed revision 1325.

Now you want to undo this and restore the old revision 1324, i.e. the state just before the remove (the dot is for 'current directory'):

$ svn merge -r1325:1324 .

If you are unsure you can do a dry-run first, where svn will print the output of the command, but not actually do anything:

$ svn --dry-run merge -r1325:1324 .

The result should indicate that the file is being added (again):

A file.txt

Upvotes: 4

waney
waney

Reputation: 402

you could switch to revision where this file was exist. Edit/copy this file and switch back to the head revison and commit it here.

Also you could merge changes beetween two revisons - head and last revision file was exist in repository and apply changes to your working copy.

Upvotes: 2

Related Questions