Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What I am looking for here is how to manipulate Svn to effectively rollback my previous commit to the repository without affecting the changes I have made locally.

Let's say I do this:

$ svn ci -m "Updated abc"
Transmitting file data .
Commited revision 123

And then realise that I don't want to make that update on the repository yet, but want to keep the changes I have made locally. I want my local files to stay the same, but the files on the repository to go back to revision 122.

I have only manged to find one way of doing this, is using a reverse merge:

$ svn merge -c -123
--- Reverse-merging r123 into 'integer.c':
U    integer.c
$ svn commit -m "Undoing last change: rev 123."
Transmitting file data .
Committed revision 124.

Unfortunately this means that I have to copy my local files elsewhere, before doing the reverse merge, and then copy my local file back after the commit.

I was wondering if there was a less circuitous way of doing this, where the operations only take place on the repository?


share|improve this question
up vote 2 down vote accepted

1. Checkout new repo copy

2. Run:

svn merge -rHEAD:XXXX

(XXXX is the revision BEFORE the one you just committed)

3. Commit

4. Delete newly checked-out repo

share|improve this answer
Oooh nice one! Can't believe I didn't think of that one. Thank you! – bguiz Nov 22 '09 at 1:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .