Monday, February 11, 2008

How to Rollback a SVN Repository to a Previous Revision

Sometimes you might get confused about what to do if you accidentally commit something to a SVN repository. If you want to rollback the SVN repository to the revision before your last commit, this is what you need to do.

a) Update your local copy of the code base to the latest revision.

b) Merge the previous revision to your current code base.

svn merge -rHEAD:xxxx [svn-repository-url] [path-to-local-copy]
  • HEAD – indicates the revision of the local copy of the code is the latest revision.
  • xxxx – is the revision which want to rollback.
  • [svn-repository-url] - is the project's URL in SVN repository
  • [path-to-local-copy] - is the path to the local copy of the project
svn merge -rHEAD:1010 /home/sanka/project1/trunk

c) Commit the changes which occurs as a result of above steps.