Jason S
Jason S

Reputation: 189876

svn: reverting to previous version

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.

Upvotes: 8

Views: 28003

Answers (3)

harald
harald

Reputation: 6126

svn merge -c-301 .
svn commit -m "Reverting commit 301"

Upvotes: 1

DigitalRoss
DigitalRoss

Reputation: 146251

svn merge -r301:300 foo.txt
svn commit -m 'revert foo.txt to 300'

Upvotes: 15

JoshD
JoshD

Reputation: 12824

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).

Upvotes: 9

Related Questions