Easy Tutorial
❮ Svn Check Out Svn Tutorial ❯

SVN Version Revert


When we want to abandon changes to a file, we can use the SVN revert command.

The svn revert operation will undo any local changes in files or directories.

We made changes to the file readme and checked its status.

root@tutorialpro:~/svn/tutorialpro01/trunk# svn status
M       readme

At this point, we realize the changes were incorrect and want to undo them, so we revert the file readme back to its unmodified state using svn revert.

root@tutorialpro:~/svn/tutorialpro01/trunk# svn revert readme 
Reverted 'readme'

Checking the status again.

root@tutorialpro:~/svn/tutorialpro01/trunk# svn status 
root@tutorialpro:~/svn/tutorialpro01/trunk#

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

svn revert -R trunk

However, what if we want to revert to a previously committed version?

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

First, find the current version of the repository, which is now version 22, and we want to revert to a previous version, such as version 21.

svn merge -r 22:21 readme
❮ Svn Check Out Svn Tutorial ❯