Tuesday, August 5, 2008

Moving on from CVS to Git — How to do the import

Ok, so now Git will be it, what to do? There's git-cvsimport(1), included in git-core. Other people suggest cvs2git(1), especially for complicated histories, i.e. histories with lots of branching and merging. But as branching and merging is a major pain with cvs, I have mostly boringly simple histories, regular release tags and occasional branches being the most complicated stuff. When I organized my CVS repositories when setting them up I majorly messed things up so I want to use the chance to reorganize my repositories and the modules in them. However, git-cvsimport(1)'s man page reads
git-cvsimport [blah] [blah] [cvs_module]
Yeah, that's right, a single module. Googling for hours didn't really reveal anything except trying to rewrite history by using git-filter-branch(1). Being a complete git-noob I decided that's a little too advanced for me. To be honest I hardly understand the man page. kampasky_ on #git gave me the golden clue: simply move the modules you want to intermingle from as many CVS repositories as you like into a common subdirectory (a new ”supermodule” so to speak) and import that. So to transform
CVSRepo1/
    moduleA/
    moduleB/
CVSRepo2/
    moduleN/
into
GitRepo
    moduleA/
    moduleB/
    moduleN/
use the commands
$ cp -pR CVSRepo1 ImportRepo
$ mkdir ImportRepo/git
$ mv ImportRepo/module* ImportRepo/git/
$ cp -pR CVSRepo2/moduleN ImportRepo/git/
$ mkdir NewGitRepo
$ git cvsimport -A authors-conv.txt -d ImportRepo -C NewGitRepo git
If you get the dreaded “git-cvsimport: fatal: cvsps reported error” error message while trying to import be sure to read my next post tomorrow.

No comments: