Previous Section  < Day Day Up >  Next Section

Recipe 18.7. Adding New Files to a CVS Repository

18.7.1 Problem

You have created a new file, and you need to add it to your local CVS repository.

18.7.2 Solution

Run these commands from your working directory, or sandbox. In this example, the new file you have created is cleverly named "newfile," and it is in your sandbox:

$ cvs update

cvs update: Updating .

? newfile

$ cvs add newfile

cvs -d /home/jenn/cvsroot add newfile

cvs add: scheduling file `newfile' for addition

cvs add: use `cvs commit' to add this file permanently

$ cvs commit -m 'simple Ethereal filter for monitoring HTTPS traffic' newfile

/home/jenn/cvsroot/scripts/newfile,v  <--  newfile

initial revision: 1.1

18.7.3 Discussion

When you run the update command, the question mark shows which files have not yet been committed to the CVS repository.

The update command synchronizes changes from the repository to the sandbox (not the other way). Use the status command to see the differences first, without making any changes in your sandbox:

$ cvs status

The commit -m command demonstrates how to create a log entry for a single file on the command line, to avoid invoking a text editor. It's nice little timesaver.

Keep in mind that when you edit a file to a point where you want to preserve it, the thing to do is check it into the repository. Don't leave it lying around in your sandbox. When you start work for the day, you should run update first thing to bring your local copies up-to-date.

Even when you're the only user of a repository, it's a good idea to keep your sandbox in sync with the repository. But in a shared repository, it's very important to stay synchronized—it's much easier to deal with small conflicts than larger ones, and if you're synched, conflicts are rarer.

18.7.4 See Also

  • Chapter 3 of Essential CVS

  • "A.18 update—Bring work tree in sync with repository" (/usr/share/doc/cvs/html-info/cvs_16.html)

  • CVS home page (https://www.cvshome.org)

    Previous Section  < Day Day Up >  Next Section