Migrating from RCS to a git repository

Way back in the day, I used RCS to do version control for configuration files (a trick that Hugh Daniel taught me), as well as for single-file scripts. I always used CVS and later Subversion for larger, multi-file projects, but for a single file, RCS was all I ever needed.

Recently I’ve had to migrate code to a git repository at work, and for historical purposes I’ve wanted to include the RCS checkin history for these scripts.

The best tool I’ve found for this is rcs-fast-export. The command sequence looks something like:

cd ~/src
mkdir -p project-directory/RCS
mv RCS/script,v project-directory/RCS/script,v
mv script project-directory
cd project-directory
git init
~/src/rcs-fast-export/rcs-fast-export.rb script | git fast-import && git reset

This of course presumes you’ve cloned rcs-fast-export into a subdirectory of your ~/src directory, which you’d do with the following commands:

cd ~/src
git clone https://github.com/Oblomov/rcs-fast-export.git

Once you’ve imported your history, git log and all other sensible git commands will work as expected.