This should be straightforward, but it’s not. To import (not track, but just import) code from a remote CVS repository to a local git repository, you need to do the following:
- Be certain you have the git-core package installed on your system and that this package includes the
git-cvsimport
command. You can rungit help -a | grep cvsimport
to verify this. - Be certain you have the
cvsps
command-line tool installed. This does not come with the git suite of tools, so you’ll need to get it separately. If you’re a lazy Mac OS X user, like me, you can use MacPorts:sudo port install cvsps
. Otherwise, get it from the source. - Prepare your CVS login information for the remote server before you run
git cvsimport
. You need to do this so that the git tool will be able to log you in to the CVS server automatically. The command for this looks like:CVSROOT=:cvs-login-method:cvs-user-name@cvs.server.name:/path/to/CVS/root cvs login
For example, if you’re pulling code from the anonymous CVS server that runs on Drupal.org, you might use this:
CVSROOT=:pserver:anonymous@cvs.drupal.org:/cvs/drupal-contrib cvs login
. This command will prompt you for the password for the user you specified at the server you specified (for anonymous access, the password is almost alwaysanonymous
) and will hash this in the~/.cvspass
file for future use by CVS - Finally, run the
git cvsimport
tool, and specify the proper options. Using the Drupal example above, your command might look like this:git cvsimport -v -d :pserver:anonymous@cvs.drupal.org:/cvs/drupal-contrib contributions/modules/module-name
This would login to
cvs.drupal.org
using the CVS’spserver
login method, provide the usernameanonymous
and the password you specified in the previous step that is hashed in~/.cvspass
, set the CVS document root to/cvs/drupal-contrib
, and pull the code located atcontributions/modules/module-name
into the current working directory as a git repository.
This works pretty nicely, and creates a git repository just as though you’d created it with git init
in the current working directory.
If you get an error that looks like this:
AuthReply: cvs [pserver aborted]: descramble: unknown scrambling method
then you’ve most likely specified the CVS document root incorrectly. Most notably, git cvsimport
does not understand a CVS document root wherein the password is specified in the document root URL itself. So, for example, git cvsimport -d :pserver:password:username@cvs.server.name:/path/to/CVS/root code/to/checkout
will not work. Omitting the password and the separating colon from the URL should fix it.
Hello guys. I’m new here and wanted to say hi.
Thanks for this, was trying to checkout a d.o module with git and getting the old I HATE YOU message. Installing cvsps, using the CVSROOT env variable and running cvsps did it for me.
Thanks for the post Meitar
Hi,
Just wanted to say thank you. These set of instructions worked for me to import a project from Subversion into Git.
The command I used was:
git cvsimport -v -d :pserver:my_username@jungerl.cvs.sourceforge.net:/cvsroot/jungerl jungerl/lib/ibrowse
just wanted to say thanks! :) this was a lot of help!
Thank you for this. After a few false starts (case-sensitivity, forgetting to cd to the correct dir), I am now importing the CVS repo I need!
This method isn’t working for me..unfortunately.
I’m only able to contact the remote CVS server with the following command
git cvsimport -v -d :pserver::@:/path/to/repo -o master path/to/module
Then I get a cvs rlog command message per folder in that module. Something like
cvs rlog: Logging path/in/module
cvs rlog: Logging path/in/module
…
It seems all paths are iterated but at the end I get an error message
Error: log file parsing error. (3) Use -v to debug
As shown above I’m using that option. And nothing is checkout from the CVS server.
Am I missing anything?
It wasn’t clear to me what a CVS module is.
It turns out it’s just a top-level directory name without forward slash!
Thanks! Excactly what I needed, worked just great!
Hi —
I am trying to run the same import from a linux machine. I got cvsps installed and trying to run the command and i keep getting this error
fatal: Needed a single revision
Branch ‘origin’ does not exist.
Either use the correct ‘-o branch’ option,
or import to a new repository.
Also the cvs url i have has a port
so i have the root url as
:pserver:user@server:port module
if i add a : between the port and path i get
AuthReply: error 0 :/cvsrepos: no such repository
and when i try to run without the : i get the error mentioned previously.
Thanks
Gopi
Hi —
I found out the issue. The location when i was trying to import already has a .git folder which i need to remove.
its now importing.
Thanks
Gopi
Hello friends i want to migrate cvs repo to git repo for windows7.
I have 2 problems
1.cvsimport command is not working in git command line how it will work.
2.how to install cvsps for windows7.
please someone help me.
Thanks
Now i migrate local CVS repository to Git repositopry successfully.
Thanks
Ajit, how did you manage to get cvsimport and cvsps on windows 7? I am stuck with the same issue, my CVS repository is on Linux.
Sebastian, sure i will help you. i hope your local system is windows. if so u need to install Cygwin with below packages.
1.Git
2.cvs
3.cvsps
4.python
then follow upper steps. i am also able to migrate code from remote repository by using same steps. if u get any error ,please share .
Thanks
Ajit
For AIX-Users:
cbtcommon/tcpsocket.h:33: error: expected ‘;’, ‘,’ or ‘)’ before ‘.’ token
cbtcommon/tcpsocket.c: In function ‘tcp_accept_connection’:
cvsps has Problems with “const char *rem_addr”.
Just rename rem_addr to another variable and it works.
I am getting the following problems when I run the git cvsimport command.
Initialized empty Git repository in /home/kashif.nazar/MyProject/.git/
parse error on third token
After logging of a number of files the program ends up with the error:
“* UNKNOWN LINE * Branches:”
What can I do to avoid these problems?