The Oops Command
Often when you are changing code, you will realize that you have meandered down the wrong coding path. You can take the manual approach and try to back out of your changes but Apache Subversion gives us an easier way. It is called the revert command.
If you want to have a file restored to where it was when you last checked it out, or when it was last updated, you can use the revert command to restore a file (or files). This command will appear in the context menu from your working folder if any files have been changed. Be aware that if you select a changed file and then right-click, you will only be reverting that file (or files) you have selected. To make sure you will be affecting all the files that have been modified, either right click on the top of the working folder or make sure you have selected (using the Ctrl/Key) all the files you may want to convert.
Below is an example of the first step of the revert command. Here you can decide which files to revert and which to ignore.
You can check the box of any file you may want to revert to what it looked like when it was checked out or updated. Be aware that both a files’ changes and any changed Subversion properties will be changed by the revert command.
At the bottom of the form there is a button labeled “Delete unversioned items…” This will present you with a form where any files that you have added since doing a checkout (but not added with the Subversion ADD Command) can be selected, and then deleted.
The revert command also works with folder changes. Below you see the effect of running the revert command after adding a new folder (“newfolder”) and renaming a folder (“reports” was renamed to “User_reports_renamed”).
The effect of a rename shows up as the deletion of the old folders and addition of the new (renamed) folder.
Every week WANdisco’s Head of Training Mike Lester will publish a tip to help you get the most out of Apache Subversion. Mike also delivers free, bi-weekly training webinars on topics ranging from branching and merging best practices, to Subversion in the enterprise, and advice on making Subversion agile. Register early, to avoid missing out! Enterprise Training is also available.