The easiest way of using git locally to commit to a CVS repository is to have both a git clone of the CVS repository and a CVS checkout of your repository.

Initial steps that Work for Me (TM)

  1. Create your git clone of the CVS repository:

    git cvsimport -v -a -A /tmp/lame-authors.txt -k -m -d \ lame

    The command above will create your clone of the CVS repository in the current directory which we suppose, for the sake of this discussion, is /tmp/gitified.

    If want to specify a directory different than what you're in, then you should add the option -C /path/to/git/repository.

  2. Create a checkout of the CVS repository for CVS work stuff (I'm checking out things under /tmp):

    cvs -z3 checkout lame

    This will create your CVS checkout on the directory /tmp/lame, assuming that you are working under /tmp, as I do.

Doing real work

  1. Go to your git clone (/tmp/gitified) and start hacking, committing, etc.

  2. When it is time to send your patches to the CVS repo, you have to:

    export GIT_DIR=/tmp/gitified/.git
    cd /tmp/lame
    git cherry origin master | sed -n 's/^+ //p' | xargs -l1 git cvsexportcommit -c -p -v

    This will automatically check in all the commits that you have made in the previous step.

Continuing your work afterwards

  1. First, discard your commits in your git repository, so that you don't get further problems with git cvsimport.
  2. Update your git repository with the current contents of the CVS repo:

    cd /tmp/gitified
    git cvsimport -v -a -A /tmp/lame-authors.txt -k -m -d \ lame
  3. Update your CVS repository with the current contents of the CVS repo too:

    cd /tmp/lame
    cvs update


Of course, I would prefer a simpler, leaner workflow. If you happen to have one, please let me know.

blog comments powered by Disqus