Next: [[cvs: History browsing#History browsing|History browsing]], Previous: [[cvs: Recursive behavior#Recursive behavior|Recursive behavior]], Up: [[cvs#Top|Top]] |[[cvs: Index#SEC_Contents|Contents]]||[[cvs: Index#Index|Index]]|
Next: [[#Removing files|Removing files]], Up: [[#Adding, removing, and renaming files and directories|Adding and removing]] |[[cvs: Index#SEC_Contents|Contents]]||[[cvs: Index#Index|Index]]|
cvs add filename
’ to tell CVS that you want to version control the file. If the file contains binary data, specify ‘-kb
’ (see [[cvs: Handling binary files#Handling binary files|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
-k
kflag-m
messageadd
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. See [[cvs: Guide to CVS commands#import—Import sources into CVS, using vendor branches|import]].
: 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. See [[#Removing files|Removing files]], for an example.
: The ‘-k
’ option specifies the default way that this file will be checked out; for more information see [[cvs: Keyword substitution#Substitution modes|Substitution modes]].
: The ‘-m
’ option specifies a description for the file. This description appears in the history log (if it is enabled, see [[cvs: Reference manual for Administrative files#The history file|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
’. See [[cvs: Guide to CVS commands#admin—Administration|admin]]. 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:
Next: [[#Removing directories|Removing directories]], Previous: [[#Adding files to a directory|Adding files]], Up: [[#Adding, removing, and renaming files and directories|Adding and removing]] |[[cvs: Index#SEC_Contents|Contents]]||[[cvs: Index#Index|Index]]|
status
or update
command. If you remove the file without committing your changes, you will of course not be able to retrieve the file as it was immediately before you deleted it.
* Remove the file from your working copy of the directory. You can for instance use rm
.
* Use ‘cvs remove filename
’ to tell CVS that you really want to delete the file.
* Use ‘cvs commit filename
’ to actually perform the removal of the file from the repository.
When you commit the removal of the file, CVS
records the fact that the file no longer exists. It is
possible for a file to exist on only some branches and
not on others, or to re-add another file with the same
name later. CVS will correctly create or not create
the file, based on the ‘-r
’ and ‘-D
’ options
specified to checkout
or update
.
;Commandcvs
remove
it in one step, by specifying the ‘-f
’
option. For example, the above example could also be
done like this:
remove
for a file, and then
change your mind before you commit, you can undo the
remove
with an add
command.
remove
command you can use update
to
resurrect the file:
Next: [[#Moving and renaming files|Moving files]], Previous: [[#Removing files|Removing files]], Up: [[#Adding, removing, and renaming files and directories|Adding and removing]] |[[cvs: Index#SEC_Contents|Contents]]||[[cvs: Index#Index|Index]]|
-P
’ option to
cvs update
or cvs checkout
,
which will cause CVS to remove empty
directories from working directories.
(Note that cvs export
always removes empty directories.)
Probably the
best way to do this is to always specify ‘-P
’; if
you want an empty directory then put a dummy file (for
example ‘.keepme’) in it to prevent ‘-P
’ from
removing it.
Note that ‘-P
’ is implied by the ‘-r
’ or ‘-D
’
options of checkout
. This way
CVS will be able to correctly create the directory
or not depending on whether the particular version you
are checking out contains any files in that directory.
----
Next: [[#Moving and renaming directories|Moving directories]], Previous: [[#Removing directories|Removing directories]], Up: [[#Adding, removing, and renaming files and directories|Adding and removing]] |[[cvs: Index#SEC_Contents|Contents]]||[[cvs: Index#Index|Index]]|
Next: [[#Moving the history file|Inside]], Up: [[#Moving and renaming files|Moving files]] |[[cvs: Index#SEC_Contents|Contents]]||[[cvs: Index#Index|Index]]|
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 [[cvs: Revisions#Assigning revisions|Assigning revisions]].
----
Next: [[#Copying the history file|Rename by copying]], Previous: [[#The Normal way to Rename|Outside]], Up: [[#Moving and renaming files|Moving files]] |[[cvs: Index#SEC_Contents|Contents]]||[[cvs: Index#Index|Index]]|
Previous: [[#Moving the history file|Inside]], Up: [[#Moving and renaming files|Moving files]] |[[cvs: Index#SEC_Contents|Contents]]||[[cvs: Index#Index|Index]]|
-rtag
’ and not ‘-Ddate
’ to retrieve the revisions.
* The log of changes is maintained intact.
* The revision numbers are not affected.
Disadvantages:
* You cannot easily see the history of the file across the rename.
----
Previous: [[#Moving and renaming files|Moving files]], Up: [[#Adding, removing, and renaming files and directories|Adding and removing]] |[[cvs: Index#SEC_Contents|Contents]]||[[cvs: Index#Index|Index]]|
-P
’
option, as described in [[#Removing directories|Removing directories]].
If you really want to hack the repository to rename or
delete a directory in the repository, you can do it
like this:
# Inform everyone who has a checked out copy of the directory that the directory will be renamed. They should commit all their changes, and remove their working copies, before you take the steps below.
# Rename the directory inside the repository.
Previous: [[#Moving and renaming files|Moving files]], Up: [[#Adding, removing, and renaming files and directories|Adding and removing]] |[[cvs: Index#SEC_Contents|Contents]]||[[cvs: Index#Index|Index]]|