How to revert to previous commit in CVS

Fiona T picture Fiona T · Feb 6, 2012 · Viewed 43.5k times · Source

For legacy reasons, I'm using CVS on a project. Recently I committed some changes which broke our code and I needed to revert them. What's CVS's analog of git revert -r <old_revision>?

Looking at past questions like How to revert big change, CVS commits don't group the files that were changed. Is the only way to revert by using dates?

Also, what's the best way to view past changes? CVS log outputs too much info, most of which is unnecessary. I want to see commit messages and changed files.

Answer

Dave M picture Dave M · Feb 6, 2012

CVS documentation can be found here, but from this site it tells how to revert a single file:

MAKING THE OLD VERSION THE CURRENT VERSION

Save the version of "oldfile" to something else and check out the "current" version.
Note: you must still to do update -A to get the current version, because even though you have > renamed
"oldfile" the tag is still associated with the file "oldfile" and is not removed till > update -A is done.

Then rename the "old" version to the "current" version.
% mv oldfile oldfile.old.ver
% cvs update -A oldfile
% mv oldfile.old.ver oldfile
% cvs commit -m "reverting to version 1.5" oldfile

You can now carry on checking out, editing and commiting the file as normal.

This won't handle many files in a recursive fashion, but hopefully helps.