SVN: how to return to previous revision?

Solution 1:

From the command line:

svn up -r [revision_number]

Where [revision_number] is the revision you want to revert to.

And no, you cannot delete revisions that already exist in SVN.

Solution 2:

You can simply do an update to revision using

svn up -r 10

But as Christoph has suggested this will not let you commit the changes as SVN needs you to update your working copy to HEAD before you can commit. What you can do instead is

svn merge -r HEAD:10 yourFile
svn ci yourFile -m "Reverting back to rev 10"

Solution 3:

Three options:

Reverse merge: (fastest, keeps bad revisions, adds new revision)

svn merge $(REPO)@$(GOODREV) $(WC)

SVN dump: (removes bad revisions entirely)

svnadmin dump $(REPO) -r 1:$(GOODREV) > dumpfile
svnadmin load $(NEWREPO) < dumpfile
# Now delete $(REPO), and use $(NEWREPO)

Hand editing: (removes bad revisions, unsafe, last resort)

The only reason you might need this is if for some reason you have file-level access to the repository, but no shell access. Note that this has only been tested on SVN 1.6 and 1.7.

  1. Update your working copy to $(GOODREV) (If left at HEAD, it will be unusuable after we finish.)
  2. Take any steps to secure the repo from outside access. If it's attached to a web server, disconnect it now. Third-party accesses to the repo during this process can damage it.
  3. Back up your repo. (Never hurts, just in case something goes wrong.)
  4. Change the number in db/current to the $(GOODREV). Be sure not to alter the LF line ending.
  5. Delete all numbered files (not folders) in db/revs/*/* and db/revprops/*/* that are > $(GOODREV)
  6. Delete db/rep-cache.db
  7. Update your working copy to HEAD, which should now be equal to $(GOODREV).

Note that if you are using TortoiseSVN, you must also complete these steps:

  1. Delete all files in %APPDATA%\TortoiseSVN\logcache\*
  2. Kill all instances TSVNCache.exe via the Task Manager. (There's usually one, but could be 2 on WinVista+ due to UAC security, which prevents elevated applications from interacting with a non-elevated TSVNCache.exe. The first time you open a Save As... dialog from an elevated application, an elevated TSVNCache.exe will spawn.)

This will fix the weird log display caused by TortoiseSVN's cache being in conflict with the new repo state.

Solution 4:

Get the docs from TortoiseSVN office site.

  1. Use the revision log dialog
  2. Use the merge dialog

I use method 2 and work fine on my side.

https://tortoisesvn.net/docs/nightly/TortoiseSVN_en/tsvn-howto-rollback.html