How to undelete a file with Subversive?
Asked Answered
V

7

19

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.

Volnak answered 30/1, 2009 at 21:59 Comment(0)
I
17
  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.
Interlinear answered 1/9, 2009 at 15:10 Comment(2)
Thanks for that. I found that I had to do some extra steps in my case, where there were other files modified in the same directory and the same revision as the delete. But your instructions were great.Dupaix
Thank you for the detailed steps. I also had different issues to sort out (a rogue svn:externals definition), but your instructions were a great help.Chaumont
D
4

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
Doura answered 30/1, 2009 at 23:19 Comment(0)
W
2

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.

Winne answered 30/1, 2009 at 22:54 Comment(0)
P
2

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

Parochial answered 14/1, 2016 at 9:0 Comment(0)
A
0

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?

Aeriel answered 30/1, 2009 at 23:3 Comment(0)
I
0

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".

Import answered 19/12, 2016 at 17:37 Comment(0)
E
0

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.

Extensile answered 10/2, 2018 at 15:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.