Retract accidental checkin

See the SVNBook, specifically the ‘Undoing Changes’ section, and reverse merging.

Another common use for svn merge is to roll back a change that has already been committed. Suppose you’re working away happily on a working copy of /calc/trunk, and you discover that the change made way back in revision 303, which changed integer.c, is completely wrong. It never should have been committed. You can use svn merge to “undo” the change in your working copy, and then commit the local modification to the repository. All you need to do is to specify a reverse difference:

$ svn merge -r 303:302 http://svn.example.com/repos/calc/trunk

To clarify, your initial change will still be in the repository. But you’ve now retracted it in a later revision. i.e. the repository has captured all your changes (which is really what you want! Unless you’ve checked in a plaintext password or similar!)

Leave a Comment