R – How to revert a file in a working copy to an older revision and then commit it back to the repository

svntortoisesvnversion control

What is the process for reverting files and folders to earlier revision in SVN using the windows TortoiseSVN client?

I've have tried right-clicking a file in the working copy and selecting the "Update to revision…" command and then specifying the revision number I want, but I can't commit that change back to the repository as it thinks nothing has changed in the working copy.

If I make a minor change to the file in question it errors when attempting to commit back to repository saying that it's out of date?

So I'm unsure of the process of reverting files, as this is one of the main benefits of having a version control system it seems pretty major that I don't know how to do it!?

Best Answer

Update to this revision merely makes your working copy show the revision you have selected, it does not modify the current revision. You want to use Revert.

To do this, view the log for the file (right-click/TortoiseSVN/Show log), then right-click on the revision you want in the Log Messages window, and select Revert to this revision.

Then, review the change(s), make sure everything is to your liking, and then commit.

More details from here:

You can only commit items which are up-to-date with respect to the repository. If you 'update to revision' this switches your working copy to an old revision state. It is not really very useful except as a snapshot of what the working copy looked like in a previous life. As far as SVN is concerned, the files are unmodified (assuming they were unmodified before the update-to-rev), but out of date.

"Revert to this revision" does a reverse merge of all recent revisions into your working copy. SVN considers this to be an up-to-date working copy but with local changes which just happen to make it look the same as an earlier revision. Because it is up-to-date you are allowed to