Joakim Nygård Archive Linked About

Migrating source code

22 Apr 2022

When I first started programming in HyperCard and later Think C on my family’s Macintosh SE in the mid 90’s, I had never heard of version control systems. Early in the 2000’s I started using CVS and like many I moved on to Subversion and now Git. Unfortunately I did not have the foresight to migrate all my projects at the time and I now have both CVS and SVN repository backups locally on my machine.

Subversion

After some searching, the steps to migrate the Subversion repo were clear (Useful guides by Piotr Fert, Brajesh Sachan and Tommy). First restore the svn backup to a local repo using the same svnadmin that built the backup:

svnadmin load repo/dir < svnbackup

Then create an authors.txt file to map svn commit usernames to git users in this format:

username = First Surname <[email protected]>

The repo can now be checked out with git-svn and all changes will be preserved in a new git repository:

git svn clone repo/dir --no-metadata -A authors-transform.txt --stdlayout checkout/dir

Looking at the branches with git branch -a, all the SVN branches are now set as Git remotes. These can be re-branched in git on the appropriate commit hash and then removed. There are a few SVN references left to be removed

git branch -d -r trunk
git config --remove-section svn-remote.svn
rm -rf .git/svn .git/{logs/,}refs/remotes/svn/

CVS

This was not as easy as several of the suggested tools no longer works. cvs-fast-export did, however, and combined with git, the process was actually rather simple. Export the repository to a git import stream:

cd cvs/repo
find . |cvs-fast-export > ../stream.fe

Then, initialize and import into new git repo

cd ..
git init reponame
cd reponame
git fast-import < ../stream.fe

Github

To move these to GitHub, simply create a new, empty repository in GitHub, set the remote and push.

Even though I rarely, if ever, need this old code, it’s part of my history and nostalgic like old photos can be. Feels good to have salvaged part of it.