views:

151

answers:

2

To revert a particular folder in SVN to its previous state I currently use the following:

svn rm folder
svn commit -m 'removed folder to revert to previous version'
svn co http://pathto/repo/folder@268
cd folder
rm -rf .svn //recursively if many folders
svn add folder
svn commit -am 'reverted to the previous version'

Seems too much trouble for what should be a fairly common use case. I must be doing it wrong. How else can you do it?

+1  A: 

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

Larry_Croft
+5  A: 

Why not using 'svn merge'?

Assuming you want to revert from current HEAD (last commited) 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 "- 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 .
Jacek Konieczny