Over a million developers have joined DZone.
Platinum Partner

Fetching Previous Revisions in Subversion

· DevOps Zone

The DevOps Zone is brought to you in partnership with Librato.  Check out Librato's whitepaper on Selecting a Cloud Monitoring Solution.

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.

checking out 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.

svn update to past revision

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)

svn reverse merge


Published at DZone with permission of Jessica Thornsby , DZone MVB .

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}