dinsdag, november 08, 2005

Oneway CVS to GIT

The first step is to import a CVS tree into GIT:

mkdir foobar.git
cd foobar.git
git-cvsimport -p x -v -d :ext:takis@cvs.sourceforge.net:/cvsroot/someproject foobar

We will not make any modifications to the project in that directory, this directory is purely intended to be a GIT conversion of the CVS repository. Instead, we'll create a clone of that archive and do our hackery in there:

git clone -l foobar.git/ foobar-pi.git/

The "l" flag makes sure that git uses hard links instead of copying files, if possible.

Next, we'll make some modifications to the project and commit them using git-commit or cg-commit. As said earlier, we'll make those modifications in the foobar-pi.git directory:

cd foobar-pi.git
... do stuff ...

If new changes are committed in the CVS repository, we need to fetch those in our foobar.git repository, which is kind of a GIT mirror of the online CVS repository.

cd foobar.git
git-cvsimport -p x -v -d :ext:takis@cvs.sourceforge.net:/cvsroot/someproject foobar

Now, we'll pull in the CVS-commits to the clone directory.

cd foobar-pi.git
git pull

This results in a way to have a nice GIT repository of a project being hosted using CVS. Your GIT repository makes it easy to view changes in the project as you've got the full history locally on your system.

To prepare you modifications to be send as a patch, do the following:

git-format-patch origin..HEAD

This will give you a set of files, containing patches, which you can post to a mailinglist or maintainer.