现在的几个git项目,都是直接从cvs里checkout一份出来后
直接使用git init来初始化git仓库的
这样做的缺点是,不能把cvs里的commit信息给带过来
于是,就使用git cvsimport来迁移CVS的module
原以为,很简单的,没想到还是折腾了好长时间…..
简单记录一下使用的步骤吧

1.在使用cvsimport之前,需要安装cvsps,否则会报错
  

Can't exec “cvsps”: 没有那个文件或目录 at /usr/local/libexec/git-core/git-cvsimport line 633, line 3.


   可以在http://www.cobite.com/cvsps/上下载cvsps-2.1.tar.gz
  
make && make install

2.开始执行命令迁移
  注意,在使用cvsimport之前,需要首先cvs login一下,否则会有权限问题
  
mkdir test_module.git
cd test_module.git
export CVSROOT=:pserver:user@xx.sohu.com:/opt/cvsroot
cvs login
git cvsimport -v -d :pserver:user@xx.sohu.com:/opt/cvsroot/ test_module

   此时,报错了
  


   cvs rlog: Logging activity
   cvs: lock.c:178: lock_name: Assertion `(__extension__ ……. Terminated with fatal signal 6
  


   于是,上网Google以一把,发现这是CVS的一个bug,我们CVS repositories的目录/opt/cvsroot实际上是一个软连接
  指向/var/spool/cvsroot,cvs在处理软链接时似乎有一定的问题
  改成如下命令后
  
git cvsimport -v -d :pserver:user@xx.sohu.com:/var/spool/cvsroot/ test_module

   又报错了
  


   AuthReply: error 0 /var/spool/cvsroot: no such repository  
  


   提示,找不到这个repository,于是怀疑可能是cvs配置的问题
  修改cvs服务器上的/etc/xinetd.d下的cvspserver文件,增加一个–allow-root,如下:
  
server_args = -f –allow-root=/opt/cvsroot –allow-root=/var/spool/cvsroot pserver
  
  然后再重启cvs服务
  
service xinetd restart

   最后,再执行cvsimport就可以了

   通过cvsimport转换后,再执行
   cd test_module.git
git remote add origin git@xx.sohu.com: test_module
git push origin master

   就把当前的test_module push到远程仓库了