Roland's homepage

My random knot in the Web

Converting RCS history to git

date: 2017-08-13
modified: 2022-01-14
reading time: 2 min.
category: problems
tags: RCS git

Before the rise of git, I used rcs as my version control system. Because I want to standardize on git, I am slowly converting old repositories.

In this article, as an example, I’ll be converting my old perl scripts in ~/src/perl.

Create a fast-import stream

From the existing repo, we create a fast-import stream using cvs-fast-export.

Note that while cvs-fast-export still uses the master branch, but as of git 2.28, this is no longer hardcoded and depends on the init.defaultBranch config setting. On 2021-01-01, I changed that to main. So we have to fix that in the fast-import file.

cd ~/src/perl
find . | cvs-fast-export -A ~/archive/authormap |\
sed -E '/^(reset|commit) refs\/head/s/master/main/' > ../perl.fi

Create the new repo

Next, we create a new directory and initialize it as a git repo.

cd ~/src
mkdir new-perl
cd new-perl
git init .

Performing the import

Now we import the RCS data.

git fast-import <../perl.fi
git checkout

Commit changes that were not committed to RCS

There might be changes in the directory that were not recorded in RCS. In this case we will import them all in one go, just to capture the state of these files.

cp ../perl/*.pl .
git add .
git commit -m "Record uncommitted changes."

Update directories

For a time, we want to keep the old data around just in case we missed something. However, the new git repo is now the canonical source.

cd ~/src
mv perl old-perl
mv new-perl perl

For comments, please send me an e-mail.


Related articles


←  Moving scripts to a private repo Disable firefox DNS  →