cvs2git

Index


Introduction

cvs2svn/cvs2git is a tool that can be used to migrate CVS repositories to newer version control tools, including git. git is a distributed version control system most famous for being used for Linux kernel development. The program used to convert to git, called cvs2git, is distributed as part of the cvs2svn project.

If you are reading this documentation on the cvs2svn website, then please be aware that it describes the current trunk version of cvs2svn, which may be different than the most recent released version. Please refer to the documentation that was included with your version of cvs2svn.

Conversion to git was added in release 2.1 of cvs2svn and has improved significantly since then. Please make sure you are using an up-to-date version of cvs2svn--perhaps even the development trunk version.

Requirements

cvs2git requires the following:

Development status

Most of the work of converting a repository from CVS to a more modern version control system is inferring the most likely history given the incomplete information that CVS records. cvs2svn has a long history of making sense of even the most convoluted CVS repositories, and cvs2git uses this same machinery. Therefore, cvs2git inherits the robustness and many of the features of cvs2svn. cvs2svn can convert just about every CVS repository we have ever seen, and includes a plethora of options for customizing your conversion.

The output of cvs2git is one or more dump files that can be imported into git using the excellent git fast-import tool.

Although cvs2git is considerably newer than cvs2svn, and much less well tested, it is believed that cvs2git can (cautiously) be used for production conversions. If you use cvs2git, please let us know how it worked for you!

cvs2git limitations

cvs2git still has many limitations compared to cvs2svn. The main cvs2svn developer has limited git experience and very limited time, so help would be much appreciated! Some of these missing features would be pretty easy to program, and I'd be happy to help you get started.

Documentation

There is some documentation specific to cvs2git, and much of the cvs2svn documentation also applies fairly straightforwardly to cvs2git. See the following sources:

Usage

This section outlines the steps needed to convert a CVS repository to git using cvs2git.

  1. Be sure that you have the requirements, including either RCS or CVS (used to read revision contents from the CVS repository).
  2. Obtain a copy of cvs2svn/cvs2git version 2.1 or newer. It is recommended that you use the most recent version available, or even the development version.
    • To install cvs2svn from a tarball, simply unpack the tarball into a directory on your conversion computer (cvs2git can be run directly from this directory).
    • To check out the current trunk version of cvs2svn, make sure that you have Subversion installed and then run:

      svn co --username=guest --password="" http://cvs2svn.tigris.org/svn/cvs2svn/trunk cvs2svn-trunk
      cd cvs2svn-trunk
      make man # If you want to create manpages for the main programs
      make check # ...optional
      

      Please note that the test suite includes tests that are marked "XFAIL" (expected failure); these are known and are not considered serious problems.

  3. Configure cvs2git and run the conversion. This can be done via command-line options or via an options file:
    • The command-line options for running cvs2git are documented in the cvs2git man page and in the output of cvs2git --help. For example:

      cvs2git \
          --blobfile=cvs2svn-tmp/git-blob.dat \
          --dumpfile=cvs2svn-tmp/git-dump.dat \
          --username=cvs2git \
          /path/to/cvs/repo
      
    • The more flexible options-file method requires you to create an options file, then start cvs2git with

      cvs2git --options=OPTIONS-FILE
      

      Use cvs2git-example.options in the cvs2svn source tree as your starting point; the file contains lots of documentation.

    This creates two output files in git fast-import format. The names of these files are specified by your options file or command-line arguments. In the example, these files are named cvs2svn-tmp/git-blob.dat and cvs2svn-tmp/git-dump.dat.

  4. Initialize a git repository:

    mkdir myproject.git
    cd myproject.git
    git init --bare
    
  5. Load the dump files into the new git repository using git fast-import:

    git fast-import --export-marks=../cvs2svn-tmp/git-marks.dat < ../cvs2svn-tmp/git-blob.dat
    git fast-import --import-marks=../cvs2svn-tmp/git-marks.dat < ../cvs2svn-tmp/git-dump.dat
    

    On Linux/Unix this can be shortened to:

    cat ../cvs2svn-tmp/git-blob.dat ../cvs2svn-tmp/git-dump.dat | git fast-import
    
  6. (Optional) View the results of the conversion, for example:

    gitk --all
    
  7. (Recommended) To get rid of unnecessary tag fixup branches, run the contrib/git-move-refs.py script from within the git repository.
  8. The result of this procedure is a bare git repository (one that does not have a checked-out version of the source tree). This is the type of repository that you would put on your server. To work on your project, make a non-bare clone (one that includes a checked-out source tree):

    cd $HOME
    git clone /path/to/myproject.git
    cd myproject
    

    Now you are ready to start editing files and committing to git!

Converting to a non-bare repository

If you want to convert into a non-bare git repository (one including a working tree), then you need to make two changes to the above procedure:

Feedback would be much appreciated, including reports of success using cvs2git. Please send comments, bug reports, and patches to the cvs2svn mailing lists.