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

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: cvs login

    For example, if you’re pulling code from the anonymous CVS server that runs on, you might use this: 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 contributions/modules/module-name

    This would login to 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 code/to/checkout will not work. Omitting the password and the separating colon from the URL should fix it.

21 replies on “How to import CVS code repositories into Git using `git cvsimport`”

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

  2. 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 jungerl/lib/ibrowse

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

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

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

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


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


  8. 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. to install cvsps for windows7.
    please someone help me.


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

  10. Sebastian, sure i will help you. i hope your local system is windows. if so u need to install Cygwin with below packages.


    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 .


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

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

Comments are closed.