Oct 20, 2009

SVN file rollback

This is quite often operation, however, this is also a most asked question - "I just broke a build by my commit, how can I rollback my changes ?" The answer is simple, but you just need to use command line svn client instead of your favorite IDE-embedded one.  Let's say, you just comitted an updated version of Bullshit.java and it broke the build. How to rollback quickly ?

1. Navigate to bullshit.java package folder:

cd com/myapp/bullshit

2. Check current revision of broken file (let's assume, the current broken revision is 500):

svn info Bullshit.java

3. If required, ensure that previous revision is the correct working file:

svn diff -r 499:500 Bullshit.java

4. Get back the previous revision of the file:

svn merge -r 500:499 Bullshit.java

5. Commit file and fix the build:

svn ci -m "I fixed the build"

And in some cases, you'd want to rollback entire trunk or folder - in this case, it it easier to do the following actions:

1. Delete current folder or trunk:
svn delete svn://svn.host.net/some/project

2. Restore deleted folder by copying appropriate revision from history:

svn copy svn://svn.host.net/some/project@24 protocol://svnserver/some/


where 24 - is a proper revision number you want to make current.

No comments:

Post a Comment