Everything In Between

If your project so much as pretends to have a profit motive, I will tell you to go fuck yourself and your project.

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

19 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

19 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

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

    Gopinath

    14 Jun 13 at 9:15 AM

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

    Gopinath

    14 Jun 13 at 9:23 AM

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

    Ajit

    18 Jan 14 at 4:34 AM

  14. Now i migrate local CVS repository to Git repositopry successfully.

    Thanks

    Ajit

    20 Jan 14 at 6:51 AM

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

    10 Feb 14 at 9:49 AM

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

    Ajit

    12 Feb 14 at 12:12 PM

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

    ENI

    1 Apr 14 at 1:45 AM

Leave a Reply