Deleting files and foldersUse TortoiseSVN → Delete to remove files or folders from Subversion. When you TortoiseSVN → Delete a file or folder, it is removed from your working copy immediately as well as being marked for deletion in the repository on next commit.
Deleting a File or Directory svn delete file… Similarly, to remove a directory and all files that are in it, type: svn delete directory… This schedules the files and directories for removal from the Subversion repository.
First go to Recycle Bin of your local machine. Your VS code deleted files is there in Recycle Bin. So, Right click on deleted files and select-> Restore option then your deleted files will be automatically restored in your VS code.
The problem with doing an svn merge as suggested by Sean Bright is that is reintroduces other changes made in the same revision as the deletion. An svn copy is a more targeted operation that will only affect the deleted files.
Using Tortoise SVN you can resurrect a file that has been deleted from your working copy directory and from later SVN revisions, via a svn copy as follows:
The deleted file will now be in the working copy folder. To re-add it back to SVN, right click on the restored file and select SVN Commit.
NB: This method will preserve the previous history of the restored file, however to see the prior history in the TortoiseSVN log you need to make sure "Stop on copy/rename" is unchecked in the Log messages dialog.
Use svn merge:
svn merge -c -[rev num that deleted the file] http://<path to repository>
So an example:
svn merge -c -12345 https://svn.mysite.com/svn/repo/project/trunk
^ The negative is important
For TortoiseSVN (I think...)
That is completely untested, however.
Edited by OP: This works on my version of TortoiseSVN (the old kind without the next button)
The trick is to merge backwards. Kudos to sean.bright for pointing me in the right direction!
Edit: We are using different versions. The method I described worked perfectly with my version of TortoiseSVN.
Also of note is that if there were multiple changes in the commit you are reverse merging, you'll want to revert those other changes once the merge is done before you commit. If you don't, those extra changes will also be reversed.
For completeness, this is what you would have found in the svn book, had you known what to look for. It's what you've discovered already:
Undoing Changes
Resurrecting Deleted Items
Same thing, from the more recent (and detailed) version of the book:
Undoing Changes
Resurrecting Deleted Items
Use the Tortoise SVN copy functionality to revert commited changes:
Hope that helps
I always seem to use svn copy as a server operation so not sure if it works with two working paths.
Here is an example of restoring a deleted file into a local working copy of the project:
svn copy https://repos/project/modules/module.js@3502 modules/module.js
While being inside the project directory. This works as well for restoring entire directories.
If you're using Tortoise SVN, you should be able to revert changes from just that revision into your working copy (effectively performing a reverse-merge), then do another commit to re-add the file. Steps to follow are:
The easiest way I have been able to restore files and not lose revision history is using SVN copy, the merge example above to me seems like a more complex way to achieve the same thing. Why is there a need to merge when you simply want to restore a revision?
I use the following in this instance and it works quite well.
svn copy -m 'restoring file' -r <rev_number_file_to_restore> http://from/file.cs http://pathTo/file.cs
I always seem to use svn copy
as a server operation so not sure if it works with two working paths.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With