165

If I want to throw away all of my changes, and return to the code that is on the repository, I do the following:

$ rm -fr *
$ svn up

This is easy enough, but I'm wondering if there is a single command that will accomplish this, something like:

$ svn revert-all
Eric Wilson
  • 57,719
  • 77
  • 200
  • 270

5 Answers5

322

You could do:

svn revert -R .

This will not delete any new file not under version control. But you can easily write a shell script to do that like:

for file in `svn status|grep "^ *?"|sed -e 's/^ *? *//'`; do rm $file ; done
Juan Carlos Muñoz
  • 3,376
  • 1
  • 13
  • 5
  • 2
    Welcome to SO, and thanks for a thorough answer, as `svn revert -R` isn't equivalent to the two commands I gave. – Eric Wilson Nov 15 '11 at 16:41
  • 1
    For removing all files not under version control in Windows command line, the answer is here: http://stackoverflow.com/a/1502365/1385429 – Christiaan Westerbeek Sep 19 '14 at 10:20
  • User [mashzo](http://stackoverflow.com/users/3745505/mashzo) pointed out (in a now-deleted answer) that the `-R` flag may be necessary to ensure that unversioned directories are also deleted, as part of throwing away *all* changes. Consider incorporating this into your answer, if that seems appropriate to you. – Jeremy Apr 25 '15 at 17:34
30

There is a command

svn revert -R .

OR
you can use the --depth=infinity, which is actually same as above:

svn revert --depth=infinity 

svn revert is inherently dangerous, since its entire purpose is to throw away data—namely, your uncommitted changes. Once you've reverted, Subversion provides no way to get back those uncommitted changes

bilash.saha
  • 7,226
  • 2
  • 35
  • 40
19

Use the recursive switch --recursive (-R)

svn revert -R .
CLo
  • 3,650
  • 3
  • 26
  • 44
0

To revert modified files:

sudo svn revert
svn status|grep "^ *M" | sed -e 's/^ *M *//'
Eric Wilson
  • 57,719
  • 77
  • 200
  • 270
Taylor Hawkes
  • 641
  • 7
  • 10
  • I think my formatting change represents what you want. Rollback if you don't like it. And thanks, it's good to remember the bad old days of SVN ... :) – Eric Wilson Aug 04 '15 at 15:37
-1

To revert modified files:

svn revert -R <path_to_directory>
Peter Csala
  • 17,736
  • 16
  • 35
  • 75