CVS简介
版本控制系统is a version control system;
The Repository 仓库
Repository 仓库(服务器端)
Working directory工作目录(客户端)
是C/S结构的用于UNIX或LINUX平台
Creating Repository 创建仓库
1.Create repository root directory
for example:
# mkdir /export/cvs/openlab
创建目录
2.chgrp the repository's' root directory
for example:
# chgrp other /export/home/cvs/openlab
更改访问组
3.chmod the repository's' root directory
for example:
# chmod g+rwx /export/home/cvs/openlab
更改读写执行权限
4.Set up the directory as a CVS Repository
for example:
# cvs -d /export/home/cvs/openlab init
初始化
Accessing Repository
Local Reository
1.Using CVS command line with the -d option
for example:
cvs -d/export/home/cvs/openlab checkout foo
2.Set CVSROOT environment variable
csh and tcsh:
setenv CVSROOT /export/home/cvs/openlab
sh and bash:
CVSROOT /export/home/cvs/openlab
export CVSROOT
第三章 :Using CVS
Basic Use of CVS
1、CVS Command Syntax
登录 cvs login
登出 cvs logout
2、Importing Project
1 导入,将数据放置到CVS服务中
cvs import -m "这里放置一个字符串,可以为空如 :new
project"(message的缩写) jul12_cjProject tarena start
必须进入到临时目录里面
2 --把项目从仓库拿到本地目录中(本机执行)
cvs checkout jul12_cjProject;
3 cvs status --没有参数查看所有文件的状态信息
4 --提交命令
cvs commit -m(message)"这里放置一个字符串,可以描述为对该文件修改的内容"
5 --新程序文件的放入
cvs add b.txt(文件的名字)
--不这么写CVS不会帮您 管理这个文件可以用cvs status b。txt查看状态
cvs status b.txt
working revision: New file!
Repository revision: No revision control file
上面可以查看,发现没有版本号码,为什么呢。。因为你是在本地阿,要提交的服务器上就可以了。
CVS commit -m (message) "此程序添加了一个b.txt 文件";
提交完成就可以了,那么这个时候的status 就变成了Up-to-date
6. --删除文件
先在自己的工作目录中删除
rm a.txt --删除a.txt
通知CVS服务器
cvs remove a.txt --通知CVS要删除 a.txt
cvs status a.txt --查看状态
================================
FIle: no file a.txt Status: Locally Removed
...
修改提交到仓库里面
cvs commit -m "remove a.txt" a.txt
注意:在仓库中,和本地不一样,其实并没有删除,只是对文件放置在一个服务器的目录里面,不过以后使用文件的时候你不可以看见而已.
$ ls
$ mv b.txt b.java
$ ls
$ cvs remove b.txt
$ pwd
$ cd ..
$ pwd
$ cvs checkout -d other jul12_Project
更新的命令,-d包括新建立的目录.
$cvs update -d
/export/home/nanjing/sd0807/jul12
Tagging 标记
Branching分支标记
1.Making a Branch
cvs rtag -b BR_1_0 cjProject
cvs tag -b branch_tag_name [filename]
or
cvs rtag -b branch_tag_name [filename]
Branching Cont
cvs checkout -r BR_1_0 -d br1.0
$ cvs checkout -r BR_1_0 yoyodyne
or
$ cvs checkout -r BR_1_0 -d br1.0 yoyodyne
cvs diff -r1.1 -r1.6 比较不同版本之间 --side -by -side 对照显示差别
设置环境变量:.bash_profile
CVSROOT=:pserver:asd17-8@172.16.0.6:/user/cvs/openlab
export CVSROOT
保存退出,注销,重新登录
登录:cvs login
退出:cvs logout
--------命令
1、创建一个本地目录
2、导入 import:cvs import -m " new project" cjProject tarena start ---------把本地的东西导入到仓库中 N表示new的意思
tarena开发商标记 start版本的标记
3、迁出 checkout:cvs checkout cjProject --------------------------把仓库中的东西导出本地来,U表示update的意思
4、查看文件信息状态 status:cvs status a.txt
5、在本地修改后再上传 commit :cvs commit -m "new line" a.txt
6、添加 add: cvs add b.txt 之后要用 commit 提交
7、删除,先删(rm)本地文件,再用 remove :cvs remove a.txt 之后要用 commit 提交
8、改名,先在本地改(mv),再用 remove /add:cvs remove b.txt / cvs add 之后用commit 提交或者用 add
9、迁出之后改目录:cvs checkout -d other cjProject
10、更新 update :cvs update -d 如果后面跟了文件名,则更新的是这个文件,如果没有文件名,则是全部更新(定期使用 update)
11、分支 rtag :cvs rtag -b BR_1_0 cjProject
12、迁出分支:cvs checkout -r BR_1_0 -d br1.0 cjProject
13、从分支更改到主线上:改之后再用一个分支 ,最后在主线上 用:cvs update -j
14、查看日志:cvs log
15、 cvs annotate b.java
16、比较不同版本的差别:cvs diff -r1.1 -r1.6 --side-by-side