How to roll back the version of a file in CVS



February 22, 2006

Peter Bojanics put this together for OpenConcept.

Familiar scenario: someone has checked a new version of a file into the CVS tree that resulted in a regression of the application. You want to roll that version back to a known state. This brief tutorial shows how to do it. 1. First, I update my working copy to the latest version...

$ cvs update BE_Article.class P BE_Article.class

2. Now, let's find the latest stable version...

$ cvs log BE_Article.class

RCS file: /cvsroot/back-end/back-end0.5.x/class/BE_Article.class,v

revision 1.45 date: 2003/04/08 16:40:51; author: iclysdal; state: Exp; lines: +109

revision 1.44 date: 2003/04/05 23:20:51; author: mgifford; state: Exp; lines: +37 -20

3. So I want to merge changes between version 1.45 and 1.44 (i.e. backwards), into my working copy...

$ cvs update -j1.45 -j1.44 BE_Article.class retrieving revision 1.45 retrieving revision 1.44 Merging differences between 1.45 and 1.44 into BE_Article.class

4. Let's make sure that our current version matches the 1.44 version...

$ cvs diff -r1.44 BE_Article.class

Good... no output (i.e. no differences)

5. BTW, if we wanted to see the differences from the current HEAD, we would do this...

$ cvs diff -rHEAD BE_Article.class

6. Finally, we commit the current working copy, effectively rolling back the previous changes made by Ian in 1.45

$ cvs commit -m \"reverting back to state in revision 1.44 to undo some bugs\" BE_Article.class Checking in BE_Article.class; /cvsroot/back-end/back-end0.5.x/class/BE_Article.class,v BE_Article.class new revision: 1.46; previous revision: 1.45 done


About The Author

Mike Gifford is the founder of OpenConcept Consulting Inc, which he started in 1999. Since then, he has been particularly active in developing and extending open source content management systems to allow people to get closer to their content. Before starting OpenConcept, Mike had worked for a number of national NGOs including Oxfam Canada and Friends of the Earth.