Tag Archive for 'svn revert'

Subversion Tip of the Week

SVN Revert

Apache Subversion’s ‘svn revert’ command allows you to discard local changes on a file or directory and replace it with the version in the repository. This saves you the overhead of performing a fresh checkout, and is also helpful when you need to quickly resolve a conflict.

To revert the changes on a single file, run the ‘svn revert’ command followed by the file path:

svn revert (working-copy)/filename

svn revert

It’s also possible to revert all the changes within an entire directory using the –depth=infinity switch. When this switch is added, any files that have been changed within the specified directory are replaced with their repository equivalent:

svn revert –depth=infinity (working-copy)

svn revert infinity

Useful Additional Commands

  • svn status

Before discarding your local changes, you may want to review exactly which files have been altered at the working copy level by using the ‘svn status’ command:

svn status (working-copy-path)

svn status

  • svn diff

The ‘svn diff’ command prints all the changes that have been made to human-readable files within the working copy, which is useful for identifying the file(s) you want to revert. Each line is prefixed by a character representing the nature of the change:

  1. + Line was added
  2. – Line was deleted
  3. A blank space represents no change

To run ‘svn diff’ enter the following command:

svn diff (working-copy-path)

svn diff

Looking for an easy-to-use cross platform Subversion client? Claim your free 30 day trial of SmartSVN Professional by visiting: www.smartsvn.com/download