Moving and renaming files

Moving files to a different directory or renaming them is not difficult, but some of the ways in which this works may be non-obvious. (Moving or renaming a directory is even harder. the section called “Moving and renaming directories”.).

The examples below assume that the file old is renamed to new.

The Normal way to Rename

The normal way to move a file is to issue a cvs rename command.

$ cvs rename old new
$ cvs commit -m "Renamed old to new"

This is the simplest way to move a file. It is not error prone, and it preserves the history of what was done. CVSNT clients can retrieve the original name by checking out an older version of the repository.

This feature is only supported on CVSNT servers 2.0.55 and later.

Note that rename is still in testing at the time of writing, so if unsure use use one of the other methods below.

Note that rename information is a property of the directory, not the file. This behaviour is slightly non-obvious when you first encounter it. For a rename to be stored in the repository a cvs commit must be issued at the directory level, and for a rename to be picked up by other clients a cvs update must be issued at the directory level.

You can move a file to a different directory within a sandbox provided the destination directory is within the same server. In this case to avoid confusion it is recommended to commit both directories at the same time (by committing from a common parent directory).

The old way to Rename

If you are connected to a server that does not support versioned-renames, the way to move a file is to copy old to new, and then issue the normal cvsnt commands to remove old from the repository, and add new to it.

$ mv old new
$ cvs remove old
$ cvs add new
$ cvs commit -m "Renamed old to new" old new

Note that to access the history of the file you must specify the old or the new name, depending on what portion of the history you are accessing. For example, cvs log old will give the log up until the time of the rename.

When new is committed its revision numbers will start again, usually at 1.1, so if that bothers you, use the -r rev option to commit. For more information see the section called “Assigning revisions”.

Moving the history file

This method is more dangerous, since it involves moving files inside the repository. Read this entire section before trying it out!

$ cd $CVSROOT/dir
$ mv old,v new,v


  • The log of changes is maintained intact.

  • The revision numbers are not affected.


  • Old releases cannot easily be fetched from the repository. (The file will show up as new even in revisions from the time before it was renamed).

  • There is no log information of when the file was renamed.

  • Nasty things might happen if someone accesses the history file while you are moving it. Make sure no one else runs any of the cvsnt commands while you move it.

Copying the history file

This way also involves direct modifications to the repository. It is safe, but not without drawbacks.

# Copy the rcs file inside the repository
$ cd $CVSROOT/dir
$ cp old,v new,v
# Remove the old file
$ cd ~/dir
$ rm old
$ cvs remove old
$ cvs commit old
# Remove all tags from new
$ cvs update new
$ cvs log new             # Remember the non-branch tag names
$ cvs tag -d tag1 new
$ cvs tag -d tag2 new

By removing the tags you will be able to check out old revisions.


  • Checking out old revisions works correctly, as long as you use -rtag and not -Ddate to retrieve the revisions.

  • The log of changes is maintained intact.

  • The revision numbers are not affected.


  • You cannot easily see the history of the file across the rename.