Corey Floyd
Corey Floyd

Reputation: 25969

How to recover an accidentally deleted folder in a svn repository

I know how to revert to a specific revision of a folder using these instructions:

http://aralbalkan.com/1381

However, I deleted the entire folder and want to get that folder back without reverting the rest of the repository.

I tried recreating the folder and then merging the changes back, but svn knows my trick and realizes it is a new folder.

How should I do this?

Upvotes: 7

Views: 19396

Answers (3)

Cesarth
Cesarth

Reputation: 1

If you have committed the changes after recreating the folder it is possible that you have the same problem I had:

I lost my history for the files. Then I svn deleted the folder again, and when doing a

svn cp ^/path/to/directory@revisionNumber /path/to/directory 

I received this error:

svn: path "htttp://.../path/to/directory" not found for revision "revisionNumber".

In that case you can use an auxiliary folder (~/tmp/) to do an

cd ~/tmp; svn co -r revisionNumber /path/to/directory 

It will create the ~/tmp/directory/ folder with all the files it contained. suppose that the place where you deleted directory was /location/of/my/trunk/path/to/

and then issue an

 cd location/of/my/trunk/path/; svn copy ~/tmp/directory/ to/

from that path to the path it should be in your tree.

Upvotes: 0

Jon Onstott
Jon Onstott

Reputation: 13727

You could check out a new working copy, and then do an export of the folder you're interested in. Once you've exported the folder, it won't have subversion metadata in it. Then you can put the folder into the working copy that it was deleted from.

Best of luck.

Upvotes: 0

Avi
Avi

Reputation: 20142

The easiest way is probably to svn copy the tree you want, from the revision where it last existed:

svn copy src@rev dest

See the Subversion Book for details.

Upvotes: 22

Related Questions