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.
- Update your working copy to
$(GOODREV)
(If left atHEAD
, it will be unusuable after we finish.) - 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.
- Back up your repo. (Never hurts, just in case something goes wrong.)
- Change the number in
db/current
to the$(GOODREV)
. Be sure not to alter theLF
line ending. - Delete all numbered files (not folders) in
db/revs/*/*
anddb/revprops/*/*
that are >$(GOODREV)
- Delete
db/rep-cache.db
- 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:
- Delete all files in
%APPDATA%\TortoiseSVN\logcache\*
- 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-elevatedTSVNCache.exe
. The first time you open aSave As...
dialog from an elevated application, an elevatedTSVNCache.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.
- Use the revision log dialog
- 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