Fetching Previous Revisions in Subversion
One of the fundamental features of Apache Subversion is that it remembers every change committed to the central repository, allowing users to easily recover previous versions of their project.
There are several methods available to users who wish to roll back to an earlier revision:
1) Perform a Checkout
By default, Subversion checks out the head revision, but you can instruct it to checkout a previous revision by adding a revision number to your command:
svn checkout -r(revision-number) (repository-URL)
In this example, we’re creating a working copy from the repository data in revision 5.
2) ‘Update’ to Previous Revision
If you already have a working copy, you can ‘update’ it to a previous revision by using ‘svn update’ and specifying the revision number:
svn update -r(revision-number) (working-copy-location)
In this example, we’re updating the ‘Project’ working copy to revision 5.
3) Perform a Reverse Merge
Alternatively, you can perform a reverse merge on your working copy. Usually, a reverse merge is followed by an svn commit, which sends the previous revision to the repository. This effectively rolls the project back to an earlier version and is useful if recent commit(s) contain errors or features you need to remove.
To perform a reverse merge, run:
svn merge -r(revision-to-be-merged):(target-revision) (working-copy-URL)
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)