Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accidental SVN check-in

OK, this is a real-life scenario and I don't want to take risk, so I'm asking.

I and Bob are working on a .NET project (VS2010) which is under SVN. Everything was running fine till today. And then Bob made a mistake when committing. Here's a brief history of commits:

Rev. 158 - Me - All fine - I checked-in some work

Rev. 159 - Bob - All fine - Bob checked-in some work

Rev. 160 - Bob - Committed some blunders

I had continue further work after committing Rev. 158 and now my working copy contains lots of work that needs to be checked in. How can I ask SVN (I have Tortoise) to simply purge Rev. 160 and go back to Rev. 159 state? I read a few other posts and they suggest using SVN History and clicking on last good commit and choosing "Revert to this revision" command from context menu, but if I do that, it asks me if I want to revert my WORKING COPY to Rev. 159, which means I'll lose all my changes. I just want the server-side to simply undo Rev. 160 without affecting my working copy.

like image 762
dotNET Avatar asked Nov 26 '25 04:11

dotNET


1 Answers

Reverting to a previous revision is called a reverse merge in Subversion.

From the command line, you can do this:

$ svn merge -c -160 .

Note the minus sign in front of the revision. This says to remove the changes introduced with Revision 160. You can do this even after other revisions have been checked in. However, the longer you want, the more likely there could be merge conflicts.

You can also do a reverse merge in Tortoise. This can be done via the log (right click on a revision and select revert), or via the Merge dialog box (select the reverse merge checkbox).


Use AnkhSVN instead of TortoiseSVN

Since you're doing .NET development, I assume you're using VisualStudio. If you are, use AnkhSVN instead of TortoiseSVN. AnkhSVN integrates inside of Visual Studio, and knows what VisualStudio cruft not to add into the repository (unlike TortoiseSVN).

like image 136
David W. Avatar answered Nov 29 '25 18:11

David W.