SVN Version Rollback


When we want to discard changes to a file, we can use theSVN revertcommand.

The svn revert operation will undo any local changes in a file or directory.

We modify the file readme and check the file status.

root@example:~/svn/example01/trunk# svn status
M       readme

At this point we find the modification is wrong and want to undo it. Use svn revert to restore the file readme to its unmodified state.

root@example:~/svn/example01/trunk# svn revert readme 
Reverted 'readme'

Check the status again.

root@example:~/svn/example01/trunk# svn status 
root@example:~/svn/example01/trunk# 

After performing the revert operation, the readme file is restored to its original state. The revert operation can restore not only a single file, but also an entire directory. To restore a directory, use the -R command, as follows.

svn revert -R trunk

But what if we want to restore an already committed version?

To eliminate an old version, we must undo all changes in the old version and then commit a new version. This operation is called a reverse merge.

First, find the current revision of the repository. It is now revision 22. We want to roll back to a previous revision, for example revision 21.

svn merge -r 22:21 readme 
Other Extensions