Import Subversion Repositories to Git

Install the git-svn package:

sudo apt install git-svn

Create a file named authors.txt with a mapping between SVN user names and Git authors. For example:

guyru = Guy Rutenberg <guyrutenberg@gmail.com>

Do the actual import:

git svn clone --no-metadata --stdlayout --authors-file=authors.txt file:///path/to/svn/repo

The --no-metadata option will get rid of the git-svn-id: ... lines in the commit messages. It is useful if you are doing a one-off import of an SVN repository to Git. However, if you plan to repeatedly synchronize SVN to the Git repo, that option should be omitted.

The --stdlayout flag instructs Git to assume the Subversion repository has a standard layout of trunk/tags/branches.

References:

Author: (no author) not defined in authors file

I came across the following error message:

Author: (no author) not defined in authors file

when I tried to import an SVN repository (Open Yahtzee‘s) to Git using git svn, and I specified an authors file (using -A). Indeed, the first commit to SVN (which was done using cvs2svn) had no username for the committer. Apparently, the workaround is to add the following line to your author file.

(no author) = no_author <no_author@no_author>

I also tried doing the same without an email address, but it just didn’t work. It seems Git requires that all authors have an email address.

Back Up a SourceForge-Hosted SVN Repository – sf-svn-backup

SourceForge urges its users to back up their projects’ code repositories. As I have several projects hosted on SourceForge, I should do it too. Making the backups isn’t complicated at all, but because it isn’t properly automated, I’ve been lazy about it.

sf-svn-backup was written to simply automate the process. The script is pretty simple to use: just pass the project name as the first argument, and the script will write the dump file to stdout.

For example:

sf-svn-backup openyahtzee > openyahtzee.dump

The project name should be its UNIX name (e.g. openyahtzee and not Open Yahtzee). Because the script writes the dump file directly to stdout, it’s easy to pipe the output through a compression program such as gzip to create compressed SVN dump files.

Delete Unversioned Files Under SVN

Sometimes svn switch fails because unversioned files exist in the working copy, and the need to erase them comes up. This is also true when updating to an old revision (usually one that misses directories that exist in the head revision), doing some work (like compiling), and then trying to update back to the head revision. Subversion (SVN) will fail, complaining that directories/files already exist.
Continue reading Delete Unversioned Files Under SVN

Creating a Local SVN Repository (Home Repository)

In this tutorial, I will explain how to create a local Subversion (SVN) repository intended for a single user. I assume that you already know the benefits of keeping track of old revisions of projects or important documents such as a resume or a thesis you have been writing. Subversion offers you a very convenient yet powerful method to do so, and the easiest way to do so with Subversion (SVN) is to create a local home repository intended for a single user – you.
Continue reading Creating a Local SVN Repository (Home Repository)