Reverting All Local Changes in SVN

Whenever I apply somebody else’s big patch to review it, I obviously go ahead and revert the changes to my local Subversion working copy afterwards. Here’s the line I use to do it, maybe somebody will find it useful (though I mainly blog it not to forget it myself):

svn st -q | awk '{print $2;}' | xargs svn revert

(To be honest, I also expect about 17 comments now that tell me how I can do this more efficiently, or what I didn’t consider when writing this in about 5 seconds — so, don’t disappoint me, fire away! :) )



6 Responses to “Reverting All Local Changes in SVN”

  1. svn revert -R .

  2. Haha, see — I knew it! Thanks!

    (Of course you do need to admit, my way looks way cooler ;) )

  3. Eevee beat me to it, but I think it’s awesome that this is the first solution that occurred to you, even though “svn help revert” or even just Google would have made your job easier. This implies that you’re a leader, or something. :-P Also, I’m impressed at your awk skillz.

  4. Heh, thanks. I could toootally swear last time I checked svn revert’s syntax it didn’t have a recursive switch yet, but that’d probably turn out to be wrong. Maybe I wasn’t wearing my glasses or something.

    I think, actually I was just looking for an excuse to use awk in public. :-D

  5. And maybe somebody know how to revert revert?
    I have lost my all uncommited changes because of accidentally using revert :(

  6. @mrrau: No, there is no way to revert revert. When I have any doubts, I run svn diff > current-work.diff from the top of my working copy before reverting. Then you have a patch you can re-apply if you are missing something.

Leave a Reply