tags:

views:

53

answers:

3

I mistakenly committed the wrong change to file, for a simplified example's sake let's call it foo.txt:

foo.txt, rev 300 (correct):

 E = mc^2

foo.txt, rev 301 (incorrect):

 E = mc^3

How do I re-commit rev 300 to the next commit? If I update foo.txt to rev 300, I get the right file but its status is correct & doesn't require being committed.

NOTE: It's only foo.txt that I want to revert. The other revisions in rev 301 are important and I need to keep them.

A: 
svn merge -c-301
svn commit -m "Reverting commit 301"
harald
Shouldn't you undo r301 though? and I think it's a lowercase `-c`
Sander Rijken
Sander: True, fixed :)
harald
+2  A: 

If you're using TortoiseSVN, this is surprisingly easy. Just view the log for that file, right click on revision 300 and select revert to this revision (this is a local operation). Then you can commit your local file as 302.

Optionally, if this occurred quite some time ago, you can select revert changes from this revision. That will revert only the changes that occurred with that check in (you'd perform this on 301).

JoshD
No, I tried that. It lets me revert to that revision but doesn't mark the file as dirty.
Jason S
Should work, take care of choosing "revert" not "update". Sometimes the overlay icons do not display the real state. On "commit" you should see the file as dirty in the list.
jdehaan
@Jason: Odd. Last time I had to revert a revision, I did precisely what JoshD said and it worked just fine.
David Thornley
"take care of choosing "revert" not "update"" -- that may have been it. I didn't see "revert" in the list of options.
Jason S
Yeah, I just tried it again. If I right click on a file, there's an "update to revision..." but no revert; Revert is missing. No idea why.
Jason S
GACK! I just reread this answer carefully, you go through the log for that file. sigh. thanks all...
Jason S
+3  A: 
svn merge -r301:300 foo.txt
svn commit -m 'revert foo.txt to 300'
DigitalRoss