Mass revert in SVN
Ever experience merging something in SVN just to realise that merged the wrong branch or things don’t work? In few cases, you may want to revert all the changes.
So let’s start with this:
svn st
You get a list of files. But you only want those that has ‘M’ status. So, let’s to filter that using grep:
svn st | grep '^M'
Good. Now that I have only the ones that are modified, all I need is get the filename.
svn st | grep '^M' | awk '{print $2}'
This will actually list only the filename part. The ‘$2’ means print only column 2.
And finally, we run svn revert on each of the filenames returned:
svn st | grep '^M' | awk '{print $2}' | xargs svn revert
Of course, this means you can now do specific things like removing newly added files, conflicted files, etc.