Introduction to CVS Use

xiaoxiao2021-03-06  41

CVS is the front-end tool for RCS, which is used for multi-user parallel development version control tools, its biggest feature

Is it using the "Copy-Modify-Merge" mechanism rather than "Lock-Modify-Unlock". by using

CVS generates a repository of a file (Repository), which is stored in each directory in the warehouse called modules.

(Module), check the corresponding modules in the working directory in the modification (WORKING DIRECTORY)

To the corresponding directory, all modifications are completed in the working directory, and then submit them to the warehouse after the modification is complete.

It is a new version number and save it.

1. CVS initialization

-------------

(1) Create a cvsroot root directory

Edit relevant environment variables, add CVSROOT definition (for example, add it under the / etc / bashrc file

Two rows of surfaces):

Cvsroot = / usr / local / cvsroot

Export cvsroot

Then start creating cvsroot in the corresponding position

$ CD / USR / LOCAL /

$ mkdir cvsroot

$ cvs -d / usr / local / cvsroot init

At this time, the / usr / local / cvsroot / cvsroot directory will be generated, which puts the configuration of CVS.

Part. Simultaneous / usr / local / cvsroot / also stores all files as a file warehouse.

(2) Creating a development project

If a new project is started from the beginning, you need to create a separate directory and put all the texts you want to use.

A piece of effective organization. And if you have a directory that starts using the source file, you just need to enter

This directory is on.

$ CD / WORK / TANG

$ ls cvsteest

.. C /

$ cd cvstest

Then you can enter the source file directory:

$ CVS IMPORT -M "Create Source Dir" CVSTEST / C TANG CVSTEST

This will generate a $ cvsroot / cvstest / c directory. Where -M is used to specify the comment information, if later

If you do not specify an comment message, the default editor (vi) is started to enter the comment information. Tan

g, CVSTEST identifies the manufacturer and distribution identifier, respectively.

Note that using the import command will introduce all files and directories (including subdirectory) in the current directory.

The specified module (directory) in the file warehouse.

2. Command introduction

-------------

(1) Detecting source files

CVS Checkout [-r Rev] [- D Date] [- D DIR] [- J Merg1] [-J Merg2] Modules

-r detects modules of the specified version

-D to detect the module of the specified date

-d detects the specified directory instead of the module

-j merged current version and specified version

Use the following command to detect the modules that have just been generated, and generate it in the current directory.

The same directory structure:

$ CVS Checkout Cvstest / C

Modules complicated for directory structures can be specified in $ cvsroot / cvsroot / modules:

1) $ CVS Checkout CvsRoot / Modules

2) Add the following line in the modules file:

Source Cvstest / C

3) Then execute:

$ cvs commit -m "add source"

You can use the following command to generate a cvstest / c directory under the current path.

$ CVS Checkout Source

This directory generated under the current path is called a working directory, and all modifications to the source file should be done in this directory, and it is absolutely not allowed to change the files in the $ cvsroot directory in the file repository.

(2) Delete, increase, rename files and directories

CVS Add [-k kflags] [- m message] FILES ...

-k specifies the default detection directory of the file later

-m description

The above command will join a new file into the file warehouse, but until you use the submit command to really

Update the file warehouse.

Cvs Remove [options] FILES

The above command will delete a file from the file repository, but it has to be a role after committing.

Example 1: Add file

$ CVS Checkout Source

$ CD CVSTEST / C

$ Touch Test.c

$ cvs add test.c

$ cvs commit -m "add test.c"

Example 2: Delete file

$ CVS Checkout Source

$ CD CVSTEST / C

$ RM Test.c

$ CVS Remove Test.c

Use the -f option to work above two steps.

$ CVS Remove -f Test.c

If you want to recover the file just deleted before commit, you can follow:

$ cvs add test.c

If you only perform the first step (RM), you can use the following method to recover:

$ CVS Update Test.c

For renamed files, you can delete it first.

For the modification of the directory (rename), you may need to modify the CVS management file, which should generally follow the following steps.

Step:

1) Confirm that all relevant modifications have been submitted;

2) Enter the module directory to be modified in the file repository, modify the corresponding directory (renamed or delete)

$ CD $ CVSROOT / MODULES

$ mv old_dir new_dir

3) If necessary, modify management files, such as modules files

If you want to delete a directory, you should first delete each file in the directory (including using CVS REMO)

Ve) After processing, the step 2 will be executed.

(3) Submit a source file

CVS commit [-rl] [- m MESG] FILES

-R Lianzi directory

-l only submit local directory (not submitted subdirectory)

-M comment information

After detecting the source file, all modifications to the source file in the working directory must be submitted

You can work with source files in the file warehouse and new files can be assigned a new version number.

(4) Release Work Contents

CVS Release -d Source

This command will delete the working directory cvstest / C (suggesting this step after submitting the modified module)

It is better than using RM-RF Cvstest.

3. Multi-user development

---------------

In the case of multiple users, if the different users modified different parts of the same file, use the following

The command can be multi-merge (combined with the current latest version of the current):

$ CVS Update

(1) Conflict resolution

When there are multiple users to modify the same file, if the same part is modified,

If there is different words, there is an unavoidable conflict. If there is one in the CVS file warehouse

Document test.c, its version is 1.4, user A first detects the file for modification, and there is a user later

B Detecting the file for modification and submits a 1.5 in advance, and a conflict occurs when user A is submitted (if the file content is different), the CVS will prompt to resolve manually.

Version 1.4 in the file warehouse.

#include

Main ()

{

INT I;

For (i = 0; i <100; i )

Printf ("COUNT:% D / N", I);

}

User B 1.5:

#include

Main ()

{

INT I;

For (i = 0; i <10; i )

Printf ("COUNT:% D / N", I);

Printf ("over / n");

}

User A:

#include

Main ()

{

INT I;

For (i = 0; i <50; i )

Printf ("COUNT:% D / N", I);

Return;

}

The conflict will be prompted when submitting, and you need to edit it. When you run $ CVS Update, edit Test

.c, will see:

#include

Main ()

{

INT I;

<<<<<<< Test.c

For (i = 0; i <50; i )

=======

For (i = 0; i <10; i )

>>>>>>> 1.5

Printf ("COUNT:% D / N", I);

<<<<<<< Test.c

Return;

=======

Printf ("over / n");

>>>>>>> 1.5

}

(2) File version management

CVS log [-lr] [- r reg] [- d Date] [- w login] [files ...]

-l does not proceed with subdirectory

-R pair subdirectory

-r designated version number

-d specified time

-W Specify the login name

Use the above command to see all historical version information of the current module or specified file.

CVS Annotate [-lr] [- r Rev | -d Date] FILES

-l does not proceed with subdirectory

-R pair subdirectory

-r designated version number

Use the above command to see all modifications information for the specified file (after detecting).

Example: $ CVS Annotate Cvstest / C / Test.c

Output:

Version modifier modification time source code

1.1 (TANG 18-JAN-00): #include

1.1 (TANG 18-JAN-00): #include

1.1 (TANG 18-JAN-00):

1.1 (TANG 18-JAN-00): main ()

1.1 (TANG 18-JAN-00): {

1.1 (TANG 18-JAN-00): INT I = 0;

1.1 (TANG 18-JAN-00):

1.1 (TANG 18-JAN-00): for (i = 0; i <20; i )

1.1 (TANG 18-JAN-00): Printf ("COUNT:% D / N", I);

1.1 (TANG 18-JAN-00):

1.3 (TANG 18-JAN-00): Printf ("222222 / n"); 1.4 (TANG 18-JAN-00): Printf ("333333 / N");

1.1 (TANG 18-JAN-00):}

Use the following command to generate a branch versions relative to a designated host version:

CVS RTAG -B -R R_ROOT Rev_branch file_name

-b Specifies to generate a branch version

-r Specifies the backbone version number of the branch

Rev_root Dunk Version Number

REV_BRANCH branch version number

File_name specifies the file, use "." to represent all files in the current directory.

Use the above command to generate a branch version of the corresponding version number, because the CVS version number is using a number

Expressed, and the version of different files under the same module may be completely different, so use the identity

It will be more convenient.

example:

$ CVS RTAG -B -R 1.2 TLB-1 Source

After you have to access the branch version in the future, you can use the "-r" option.

$ cvs checkout -r TLB-1 Source

Switch from the current version of the current version to a branch version:

$ cvs update -r TLB-1 Source

Use the following command to view the version information:

CVS Status [-VLR] FILES

-v display all information

-L does not show sub-directory information

-R display sub-directory information

CVS Update -j Rev Module

Make the currently made to the specified version of the file.

Direct 1.1? 1.2? 1.3? 1.4? 1.5?

1.6

Branch TLB-1? 1.2.2.1? 1.2.2.2? 1.2.2.3

If you want to merge the version on the branch TLB-1:

$ cvs update -j 1.2.2.3 -j TLB-1 Test.c

The 1.2.2.3 can generate an identifier that is easy to remember through the TAG command.

If you want to merge branch TLB-1 to the trunk 1.2:

$ CVS Update -j TLB-1 Test.c

If you want to merge different versions on the trunk (note order is important, all repairs between the specified version

Change will be discarded):

$ cvs update -j 1.5 -j 1.2 Test.c

If the file between the modules between different versions is increased, you can:

$ CVS Update -a

$ cvs updata -jbranch_name

4. Use CVS on the remote machine

----------------------

There are many ways to use CVS through the network, but here only introduce a relatively simple type: through RSH

Row CVS command.

1) Add access license for local machines in the .rhosts of the remote machine:

Tom Tang

2) Use the following command to detect the module ESMSTRG

$ cvs -d: ext: tang @ esmpro: / work / cvsroot checkout source

Among them, EXT indicates that the connection method is RSH, TANG indicates local users, and ESMPRO indicates far away.

The landlord, / work / cvsroot indicates the $ cvsroot path on the remote host, which can be set locally

CVS_Server environment variables indicate this directory.

5. See help

----------------

CVS -H Command

You can see the help information for the specified command.

转载请注明原文地址:https://www.9cbs.com/read-53634.html

New Post(0)