Sometimes you just need to admit that you’ve loused things up and you want to go back to the way you had them last Thursday. It takes courage to throw in the towel, but it also takes a reasonable understanding of how to do it quickly with your tool. Here’s the simple procedure I follow when I want my
trunk restored to a previous version.
First, I have my repository laid out like this:
/myproject /tags /archive /branch /trunk
-1. Know which revision of trunk you want to restore. If you don’t, then this is all a worthless waste of time.
Also, make sure to talk to your team. You don’t want anyone trying to commit or update from trunk between steps 1 and 3. Also, they may have objections to your choice in step -1.
Backup you work in the
/tags/archivearea. I use this area for snapshots of my project that I want to name, and don’t want to see very often (I want to see project releases occasionally, so they just go in
/tags). Make sure you choose a good name (
good-namein the url below) for your archive tag.
svn cp http://url/for/my/trunk http://url/for/my/tags/archive/good-name -m "Save my messed up work."
- Delete your trunk. Now we could have simply used
cpin our last command, but we’re paranoid and want to make sure that everything worked first.
svn rm http://url/for/my/trunk -m "Start over on trunk."
- Restore the version of trunk that you want to use. In this example, we’re using revision 437 as the source of our new trunk.
svn cp -r 437 http://url/for/my/trunk http://url/for/my/trunk -m "Restore trunk to previous version."
There you have it, kids. Happy restoration.