Chapter 8. Adding, removing, and renaming files and directories

Table of Contents

Adding files to a directory
Removing files
Removing directories
Moving and renaming files
The Normal way to Rename
The old way to Rename
Moving the history file
Copying the history file
Moving and renaming directories

In the course of a project, one will often add new files. Likewise with removing or renaming, or with directories. The general concept to keep in mind in all these cases is that instead of making an irreversible change you want cvsnt to record the fact that a change has taken place, just as with modifying an existing file. The exact mechanisms to do this in cvsnt vary depending on the situation.

Adding files to a directory

To add a new file to a directory, follow these steps.

  • You must have a working copy of the directory. the section called “Getting the source”.

  • Create the new file inside your working copy of the directory.

  • Use cvs add filename to tell cvsnt that you want to version control the file. If the file contains binary data, specify -kb or -kB (Chapter 10, Handling binary files).

  • Use cvs commit filename to actually check in the file into the repository. Other developers cannot see the file until you perform this step.

You can also use the add command to add a new directory.

Unlike most other commands, the add command is not recursive. You cannot even type cvs add foo/bar! Instead, you have to

$ cd foo
$ cvs add bar

cvs add [-k kflag] [-m message] files ... Schedule files to be added to the repository. The files or directories specified with add must already exist in the current directory. To add a whole new directory hierarchy to the source repository (for example, files received from a third-party vendor), use the import command instead. the section called “import--Import sources into CVS, using vendor branches”.

The added files are not placed in the source repository until you use commit to make the change permanent. Doing an add on a file that was removed with the remove command will undo the effect of the remove, unless a commit command intervened. the section called “Removing files”, for an example.

The -k option specifies the default way that this file will be checked out; for more information see the section called “Substitution modes”.

The -m option specifies a description for the file. This description appears in the history log (if it is enabled, the section called “The history file”). It will also be saved in the version history inside the repository when the file is committed. The log command displays this description. The description can be changed using admin -t. the section called “admin--Administration”. If you omit the -m description flag, an empty string will be used. You will not be prompted for a description.

For example, the following commands add the file backend.c to the repository:

$ cvs add backend.c
$ cvs commit -m "Early version. Not yet compilable." backend.c

When you add a file it is added only on the branch which you are working on (Chapter 6, Branching and merging). You can later merge the additions to another branch if you want (the section called “Merging can add or remove files”).