3.7. Moving Files or DirectoriesThere is no CVS command designed specifically to move a file or file directory. In fact, CVS's design doesn't accommodate such moves. However, you can work around this limitation using a combination of CVS commands, or by altering the repository using operating-system commands. Moving files can make project history difficult to track, because then a file's history is recorded across two different files in different locations. Minimize this potential source of confusion by recording the new and old locations with meaningful log messages.
3.7.1. Moving FilesThe recommended way to move a file is to use cvs remove followed by cvs add, with messages that state where the file was moved from and to. This method preserves the file's history and allows reversion to earlier versions of the project in its old location. However, the messages stored with the add and remove commands are the only record of the move. Example 3-19 shows this method being used to rename the wizzard.h file. Example 3-19. Renaming a file
3.7.2. Moving DirectoriesThe recommended way to move a directory is to create the destination directory and add it to CVS. Use the technique described in the previous section to move all the files from the original directory to their new location, and use the -P flag for all checkouts and updates. By maintaining the old directory, previous releases of the project can be retrieved and the old copies of files that were in that directory are still stored in the repository. Another way to move files or directories is to edit the repository directly. See Chapter 6 for editing methods and their advantages and consequences. |