从仓库中检索出cvstest项目的源文件.
如果你已经做过一次checkout了,那么不需要重新checkout,只需要进入cvstest项目的目录,更新一把就行了:
$cd cvstest
$cvs update
一下即可.又或者你不想直接更新,只是想看看有没有更新的东西,那么:
$cvs status
这时后会打印出一长串状态报告(你可能需要用类似less这样的命令分页显示,或者定向到一个输出文件里慢慢看.),对项目中的每个文件有一份状态报告,类似这样:
===================================================================
File: foo.c Status: Up-to-date
Working revision: 1.1.1.1 'Some Date'
Repository revision: 1.2 /home/cvsroot/cvstest/foo.c,v
Sticky Tag: (none)
Sticky Date: (none)
Sticky Options: (none)
这里最重要的就是 Status 栏,这里总共可能有四种状态:
Up-to-date:表明你要到的文件是最新的.
Locally Modified:表明你曾经修改过该文件,但还没有提交,你的版本比仓库里的新.
Needing Patch:表明有个哥们已经修改过该文件并且已经提交了!你的版本比仓库里的旧.
Needs Merge:表明你曾经修改过该文件,但是偏偏有个不识相的也修改了这个文件,而且还提交给仓库了!
如果你只是想保持软件的同步的话(象我),那么上面的东西就足够用了.可是如果多人协作开发项目的话,可就不是了这么简单了.当你参加项目,维护文件时,就需要更多命令,比如说你我都是某 nasdaq 项目的开发人员:
1,你对某个文件做了修改,比如说改了ceo.c,加了一行程序:printf("where can I find VC to cheat!");
改完之后你要把修改提交给仓库,用命令:
$cvs commit -m "add a complain" ceo.c
或者就是:
$cvs commit -m "worry about money"
让cvs帮你检查哪个文件需要提交.
2,当我开始干活的时候,可能我先:
$cvs status
一把,这时候我会看到:
==================================================================
File: ceo.c Status: Needing Patch
Working revision: 1.1.1.1 'Some Date'
Repository revision: 1.2 /home/cvsroot/nastaq/ceo.c,v
Sticky Tag: (none)
Sticky Date: (none)
Sticky Options: (none)
于是我知道有人改了ceo.c,于是我就:
$cvs update ceo.c
或者干脆:
$cvs update
把ceo.c这个文件更新为最新版本,然后再干活.然后提交.
如果这天你修改了coo.c,加了一行 puts("how about another kind of bragging?");
并且提交了,但是这时候我已经 $cvs status 过了,就是说我不知道你的修改.
而我加了一行printf("You must shamelessly and seems knowingness to act as a coo");
并且傻乎乎地提交:
$cvs commit coo.c
这时候,CVS会告诉我
cvs commit: Examing .
cvs server: Up-to-date check failed for 'coo.c'
cvs [server aborted]: correct above error first!
于是我知道有个狗屎在我修改文件的当口做了提交,于是我
$cvs update
这时cvs会报告:
RCS file: /home/cvsroot/nasdaq/coo.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
Merging differences between 1.1.1.1 and 1.2 into coo.c
rcsmerge: warning: conflicts during merge
cvs update: conflicts found in coo.c
C coo.c
告诉你coo.c有版本冲突,于是我编辑coo.c,这时一般文件里看起来象这样:
...
printf("You must shamelessly and seems knowingness to act as a coo");
<<<<<<< foo.c
=======
...
puts("how about another kind of bragging?");
>>>>>>> 1.2
...
于是我把上面改成:
printf("You must shamelessly and seems knowingness to act as a coo");
puts("how about another kind of bragging?");
然后
$cvs commit -m "merged" coo.c
于是下回你再更新的时候就有新的补钉要打...如此往复,直到完成所有修改.
不过这里有一些要注意的地方就是删除程序,如果你删掉一行对你可能没有用的程序
puts("to be honest"); 而我不想删除(因为我有用),而我不知情地直接:
$cvs update
了,那么我的这行程序也完蛋了,所以这里我们要注意所有开发人员的协调,千万不要乱删东西,大不了用
#if 0
#endif