SVN Revert Trunk, remove a revision as if it never existed?

Mantisimo picture Mantisimo · Aug 26, 2011 · Viewed 40.2k times · Source

Is it possible in the svn server to remove a revision as if it never existed?

So we have the following revisions:

1004 // Commit of some bogus code that broke the build and was just wrong
1003 // Change 1.2
1002 // Change 1.1
1001
1000 *** Initial checkin

Can we we remove the 1004 in svn and revert back to 1003 as if 1004 never existed?

Forgive my ignorance, I'm still learning how to use SVN.

Answer

JB Nizet picture JB Nizet · Aug 26, 2011

These accidents hapen, and it's not a problem if SVN keeps them in its history. What is important is to fix the accident. The way to do it is to revert the changes made by this commit. use the following commands:

svn merge -r [current_version]:[previous_version] [repository_url]
svn commit -m “Reverting previous commit and going back to revision [previous_version].”

If you're using TortoiseSVN, you could just show the logs, select the commit, and choose "Revert changes from this revision" in the context menu. It will change your working copy to the previous version, and you'll just have to commit.

I guess other graphical clients have the same option.