Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Roll back or revert entire svn repository to an older revision

Tags:

revert

svn

People also ask

How do I get older versions of svn?

Using the latest versions of Subclipse, you can actually view them without using the cmd prompt. On the file, simply right-click => Team => Switch to another branch/tag/revision.

What does svn revert do?

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.


Check out svnadmin dump/load. It creates a text file with every version of your files. It may be possible to delete everything above/below a certain point and re-import it.

See for instance Migrating Repository Data Elsewhere


A "reverse" merge may be what you need. See "undoing changes" section of svn book.

E.g. svn merge -r 28:24 [path to svn]


If you have access to the SVN server, you can just edit path/db/current, put the old revision number you want to revert to (here: 24) there, and remove no longer needed revision files (i.e. 25, 26, 27, 28) from path/db/revs/0/. At least this worked for me today, after I had accidentally removed a directory in the repository.


If you really need to wipe 'evidence' that the files ever existed, you need to do the svndump/svnload actions described above.

In a 'normal' situation, where you made a mistake, you need to use reverse merge. This make sure that undoing the changes after r24 can also be reverted, diffed, etc.

The command below should work to undo your changes (you need to commit the result of the merge to reflect the merge in the repository)

svn merge -r 28:24

If you do not avail admin rights then you cannot obliterate any old revisions BUT you can still hide them extremely well with just one amazingly simple "svn copy" command (nickf and JesperE already mentioned this but in a rather cryptic way)

svn delete protocol://svnserver/some/resource
svn copy protocol://svnserver/some/resource@24 protocol://svnserver/some/resource

And that's it, revisions 25 to 28 have completely disappeared from svn log. It's not a hack at all, it is a safe and (barely...) documented feature.

If "resource" is a directory then you must strip it from the last URL:

svn copy protocol://svnserver/some/directory@24 protocol://svnserver/some/

(otherwise you would copy it inside itself)


For anyone using TortoiseSVN, the solution is simple:

  • view change log
  • right-click the revision you want to roll back to...
  • ...select "Revert to this revision"
  • commit your changes

This method preserves the version history (i.e. all of the revisions that you reverted).


You can do a new checkout of a particular revision. http://svnbook.red-bean.com/en/1.1/re04.html

svn co path/to/my/repo -r 24