Everything In Between

The brutally honest, first-person account of Meitar Moscovitz's life.

How to import CVS code repositories into Git using `git cvsimport`

11 comments

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:

  1. Be certain you have the git-core package installed on your system and that this package includes the git-cvsimport command. You can run git help -a | grep cvsimport to verify this.
  2. 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.
  3. 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 always anonymous) and will hash this in the ~/.cvspass file for future use by CVS

  4. 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‘s pserver login method, provide the username anonymous 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 at contributions/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.

Written by Meitar

April 15th, 2008 at 4:06 am

Posted in HOWTO,Mac OS X,Programming,Unix/Linux

Tagged with

11 Responses to 'How to import CVS code repositories into Git using `git cvsimport`'

Subscribe to comments with RSS or TrackBack to 'How to import CVS code repositories into Git using `git cvsimport`'.

  1. Hello guys. I’m new here and wanted to say hi.

    llamafruit

    19 May 08 at 4:12 PM

  2. 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

    George Hazlewood

    9 Jun 09 at 5:29 AM

  3. 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

    Chandru

    19 Jun 09 at 7:10 AM

  4. [...] got that from this site on how to import CVS into [...]

  5. Free Your DBI-Link, and the Rest Will Follow…

    DBI-Link is now on Github! Here’s how I did it: After banging my head against git’s, um, not terribly helpful git cvsimport docs, I asked a few people what to do. Jonathan (dukeleto) Leto pointed me to this very handy guide. Thanks to the author, M…

  6. just wanted to say thanks! :) this was a lot of help!

    vedang

    31 Mar 10 at 2:48 AM

  7. 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!

    Nate

    18 Apr 10 at 12:44 AM

  8. 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?

    Pedro Mendes

    14 May 11 at 3:25 PM

  9. 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!

    kl

    1 Apr 12 at 6:44 AM

  10. Thanks! Excactly what I needed, worked just great!

    MortenS

    2 Jan 13 at 6:45 AM

Leave a Reply