Skip to content

Instantly share code, notes, and snippets.

@MiCurry
Last active September 25, 2025 20:10
Show Gist options
  • Save MiCurry/39135383197931897ff417c8f1bc7dba to your computer and use it in GitHub Desktop.
Save MiCurry/39135383197931897ff417c8f1bc7dba to your computer and use it in GitHub Desktop.
Converting SVN Repos to Git

Converting SVN Repos to Git

Prerequisites

The reposurgon tool is the main tool to convert repositories. The documentation is really not that great IMO, but it can be found here:

http://www.catb.org/esr/reposurgeon/repository-editing.html

Converting

Setting up to Converting

Follow these instructions:

$ mkdir my_conversion
$ cd my_conversion 
$
$ svn checkout $SVN_URL # Good to make a backup
$ mv $MY_REPO my_repo_full_checkout
$
$ mkdir conversion
$ cd conversion
$
$ # Create Repotool make file and fill out the prompts
$ repotool initmake $PROJECT_NAME 
> repotool: what VCS do you want to convert from? svn
> repotool: what VCS do you want to convert to? git
> repotool: generating Makefile, some variables in it need to be set.
> repotool: generating a stub options file.
> repotool: generating a stub lift file.
> repotool: generating a stub map file.

Edit REMOTE_URL and other fields as you see fit:

EXTRAS =
REMOTE_URL = svn://svn.debian.org/SIEM
CVS_HOST = cvs.sourceforge.net
#CVS_HOST = cvs.savannah.gnu.org
CVS_MODULE = SIEM
#REMOTE_URL = cvs://$(CVS_HOST)/SIEM\#$(CVS_MODULE)
READ_OPTIONS =
#CHECKOUT_OPTIONS = --ignore-externals
DUMPFILTER = cat
VERBOSITY = "set flag progress"
REPOSURGEON = reposurgeon
LOGFILE = conversion.log

# Set and uncomment these if remote access to Subversion needs credentials.
#export RUSERNAME=
#export RPASSWORD=

Then, edit the author map in the $PROJECT_NAME.map:

# Author map for SIEM
svnUserName = First Last <[email protected]>
...

You can also fill out the other files that are created. See the documentation that was linked above.

Run the Tool

Then, type make:

$ make

Then the repo will be converted.

Use git-filter-repo to filter things (if needed)

See the git-filter-repo tools here: https://htmlpreview.github.io/?https://github.com/newren/git-filter-repo/blob/docs/html/git-filter-repo.html

Issues

Disconnections when Mirroring / Large files in SVN repo

If you have a SVN repository that has large files in it, mirroring can often stop due to disconnections. To get over this:

  1. Run make until the mirroring errors out
  2. CD into the mirror directory
  3. Run svnsync manually:
$ svnsync synchronize --source-username \"uname\" --source-password \"pw\" --steal-lock file:///path/to/where/you/wanna/mirror

You may need to repeat the svnsync command several times if it stops, but the synchronize will pick up where it left off.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment