Revert a svn folder to a previous revision

Solution 1:

Why not using svn merge?

Assuming you want to revert from current HEAD (last committed) version to revision 268:

cd folder
svn up
svn merge -r HEAD:268 .

Then resolve any conflicts manually (there should be nothing if there is no local change) and:

svn commit -m "- reverted to revision 268"

To revert single change (e.g. made in revision 666):

cd folder
svn merge -c -666 .

To revert local changes (not committed yet):

cd folder
svn revert -R .

Solution 2:

Why not using 'svn merge'? That's why: "Then resolve any conflicts manually[..]"

If I know 'folder' at revision 268 contains the consistent data I'd like to go on with, why automatically create a merge with potentially inconsistent data only to manually remove those changes later. It's error prone and defeats the purpose of my configuration management tool.

I.e. I'd prefer the recipe from the original request with a minor improvement. If you use 'svn export' to get the old revision you don't have to remove .svn files:

svn rm folder
svn commit -m 'removed folder to revert to previous version' .
svn export -r 268 http://pathto/repo/folder
svn add folder
svn commit -m 'reverted to the previous version' folder

Solution 3:

You can use svn merge for this task, see http://svnbook.red-bean.com/en/1.1/ch04s04.html#svn-ch-4-sect-4.2 for an example