Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Revert a svn folder to a previous revision

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?

like image 744
lprsd Avatar asked Feb 24 '10 09:02

lprsd


People also ask

How do I revert a directory in svn?

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 .

What is svn Revert command?

Reverts any local changes to a file or directory and resolves any conflicted states. svn revert will not only revert the contents of an item in your working copy, but also any property changes.

Can we revert commit in svn?

To revert a single commit: Go to: Subversion -> Integrate Directory... Show activity on this post. Note that the svn merge command reverts a commit in the sense of having another commit undoing your changes, but keeping your wrong commit in the history.

How do I find a particular revision in svn?

If you want to write a script which requires no input, you should use the official Subversion command line client instead. checkout a working copy in REV revision: svn checkout --revision REV https://svn.example.com/svn/MyRepo/trunk/ svn checkout https://svn.example.com/svn/MyRepo/trunk/@REV.


1 Answers

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 . 
like image 177
Jacek Konieczny Avatar answered Oct 08 '22 02:10

Jacek Konieczny