Recover Deleted Files Using TortoiseSVN

During a recent cleanup of a repository I deleted a bunch of files that were largely useless and never should have been added in the first place. A little while later I discovered I had deleted a couple files that were needed and had to restore them. I mainly use TortoiseSVN to manage my repositories and looking around through it's options I did not see any type of restore option anywhere.

After a little google-fu I found that the most common way to recover a file is to use a svn copy command to copy the file from the revision just prior to the delete into the current working copy. The full command would look something like this:

svn copy your_file.php

That will copy the file your_file.php from revision 1234 and add it to the current working copy. Since I only had TortoiseSVN and not the command-line tools I wanted to find a way to do this using it rather than have to go get a command-line version of SVN.

The answer appeared in the Repository Browser feature of TortoiseSVN. There you can change the current revision you're looking at to the revision just prior to the delete. Use the log viewer to find which revision the file was deleted in if you are unsure.

Once you have changed to the correct revision, locate the file you want to restore and right-click on it to open the options menu. Select the Copy to working copy... option.

A browse window will popup asking you where you want to save the file too. Browse to your working copy and save the file where you want it. When you're finished restoring all the files you need, just run a SVN commit to commit the changes and you're done!

Support free Wi-Fi

Support free maps