如何在CVS仓库的子目录中添加新目录?
Ah, I’ve run into this exact CVS quirk before! The issue stems from CVS’s strict rules about tracking directories and where you can run commands—let me break down why your approach isn’t working and walk you through the correct workflow.
Why Your Current Method Fails
That error message usually signals one of two problems:
- You’re trying to run
cvs addin a directory that’s not tracked by CVS (no.CVSsubfolder exists there), even if you checked out the parent directory. - You might be accidentally working directly in the server-side repository filesystem instead of your local checked-out workspace. CVS requires all changes to go through a local checkout, not direct server edits.
Correct Steps to Add a Subdirectory
Follow these steps to properly add a new subdirectory inside repository/directory:
Step 1: Confirm you’re in a tracked local workspace
Navigate to your local checked-out project root (where the top-level.CVSfolder lives). If you’re inrepository/directory, double-check that a.CVSsubfolder exists here. If not, runcvs checkout repository/directoryto pull the tracked version of this directory.Step 2: Create the new directory locally
Run the standard mkdir command to create your folder:# If you’re at the project root mkdir repository/directory/new_dir_name # Or if you’re already inside repository/directory mkdir new_dir_nameStep 3: Tell CVS to track the new directory
From either the project root or therepository/directoryfolder (the one with.CVS), run:# If inside repository/directory cvs add new_dir_name # If at the project root cvs add repository/directory/new_dir_nameYou’ll see a confirmation message like
Directory /path/to/repository/directory/new_dir_name added to the repository.Step 4: Commit the change to the repository
This is critical—CVS won’t actually create the directory in the remote repo until you commit it:# Commit just the new directory cvs commit -m "Add new subdirectory: new_dir_name" repository/directory/new_dir_name # Or commit all pending changes if you prefer cvs commit -m "Add new subdirectory and updates"
Extra Tips to Avoid Future Issues
- Never edit or create folders directly in the server-side CVS repository (e.g., the
CVSROOTor project repo folders on the server). Always use your local checkout. - If you get the "no version here" error again, run
cvs updatein the parent directory to sync your local workspace with the repository. - After adding the directory, you can add files inside it with
cvs addas usual, then commit those files separately or in the same batch.
内容的提问来源于stack exchange,提问作者Josh

