It is assumed here that the directory of the SVN project is /data/svn/project, and we want to exclude the trunk/test.exe file and the trunk/notallowed/ directory. The steps are as follows and the executed svn command (in the bin directory of the svn installation directory) is as follows:
# First export the entire svn library
svnadmin dump /data/svn/project > project_original.dump
# Then exclude unnecessary files in the project_original.dump file and generate a new dump file
type project_original.dump | svndumpfilter exclude trunk/test.exe trunk/notallowed > project_new.dump
# Next create a new svn project and import the above dump file into a new project
svnadmin create /data/svn/project_new
svnadmin load /data/svn/project_new < project_new.dump
Finally, delete the original project directory and change project_new to project. It should be noted that the dump command will export all modifications and history records in the svn project, so the exported dump file will be large and the import time will be relatively long.
Completely delete some folders or files in the SVN repository from the server side
If you want to completely delete a folder or file in the SVN repository, you can use this method (for example):
Example: Assume that the SVN library path is E:/svn/project, and the directory structure in the library is
QA/Trunk
Software/Tags/test.exe
Delete the test.exe file in the Software/Tags/ directory
The steps are:
Dump the SVN library and use svndumpfilter to filter out the files to be deleted. Create a new SVN library and load the processed files into the new SVN library. The specific command is:
>svnadmin dump E:/svn/project > aaa.dump
>type aaa.dump | svndumpfilter exclude /Software/Tags/test.exe > bbb.dump
>svnadmin create E:/svn/project_new
>svnadmin load E:/svn/project_new < bbb.dump
Then rename the new project_new to project. The previous project can be moved or given another name. (Because the SVN directory used in TRAC is project, the SVN directory used by users is also project)
This method can achieve the effect of completely deleting a certain folder or file in the SVN repository when there are not many versions in the SVN repository. However, if there are too many versions in the SVN repository, there will be insufficient storage space when dumping the version. The version cannot be dumped. It becomes inoperable. At this time, another hard disk must be installed that can satisfy its storage space.
How to recover deleted files or folders with SVN
Using TortoiseSVN:
1. In the local working copy, use TortoiseSVN->Show log to view the history of the repository. You can use search.
2. Find the version where the file or folder was deleted, and right-click Revert the changes from this revision in the Log message.
3. The file or folder is restored to the local working copy. If it was deleted by mistake, just commit it to the Repository.
Using the Subclipse plug-in for Eclipse:
1. Use Team->Show SVN Repository History to view the history of the repository.
2. Find the version where the file or folder was deleted, right-click Revert to XX version.
3. The file or folder is restored to the local working copy. If it was deleted by mistake, just commit it to the Repository.