O'Reilly logo

Version Control with Subversion, 2nd Edition by Brian W. Fitzpatrick, Ben Collins-Sussman, C. Michael Pilato

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Undoing Working Changes

Suppose, while viewing the output of svn diff, you determine that all the changes you made to a particular file are mistakes. Maybe you shouldn’t have changed the file at all, or perhaps it would be easier to make different changes starting from scratch.

This is a perfect opportunity to use svn revert:

$ svn revert README
Reverted 'README'

Subversion reverts the file to its premodified state by overwriting it with the cached pristine copy from the .svn area. But also note that svn revert can undo any scheduled operations—for example, you might decide that you don’t want to add a new file after all:

$ svn status foo
?      foo

$ svn add foo
A         foo

$ svn revert foo
Reverted 'foo'

$ svn status foo
?      foo

Note

svn revert item has exactly the same effect as deleting item from your working copy and then running svn update -r BASE item. However, if you’re reverting a file, svn revert has one very noticeable difference—it doesn’t have to communicate with the repository to restore your file.

Or perhaps you mistakenly removed a file from version control:

$ svn status README

$ svn delete README
D         README

$ svn revert README
Reverted 'README'

$ svn status README

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required