Effortless SVN to Git Migration: Retain Your Complete Commit History

Ahmed K.
3 min readMay 26, 2024


Photo by Yancy Min on Unsplash

Apache Subversion, while once popular, has become outdated and falls short in several areas, such as not supporting local branches and having limited merge capabilities. If you have a legacy project currently managed in SVN, you can seamlessly migrate to Git while preserving all of your branches, tags, and commit history.

There are several tools available to convert your SVN repository to Git. In this tutorial, we will focus on using the git svn tool, which, despite requiring some additional steps and commands, provides a robust and reliable migration process.

Let’s dive right in, as you’ve likely been eager to find a comprehensive guide for this migration.

First, ensure that you have Git installed, as the git svn tool is included with Git. You can download Git from here. MacOS users may also need to install git-svn separately, which can be obtained from Homebrew.

Step1: Import SVN Authors

First of all we have to import all the authors from the SVN repo in a text file. Suppose we need to migrate the SVN repository located at https://mysvnhost/mypath/mysvnreponame

svn log https://mysvnhost/mypath/mysvnreponame - quiet | 
grep -E "r[0–9]+ \| .+ \|" |
cut -d'|' -f2 |
sed 's/ //g' |
sort |
uniq > ~/path/to/authors.txt

Open the file authors.txt you just created with a text editor of your choice and modify the lines as follows:

svn-user = git-user <git-email>

one line per user (including angle brackets ‘<’ and ‘ >’), e.g.:

a.khan = Ahmed K<ahmed.k@email.com>

And for the last line add

(no author) = gitsvn <gitsvn@gitsvn.com>

Step2: Initializing new git repository

Create a new directory and initialize a new git repository as:

git svn init https://myhost/mypath/myreponame --stdlayout --no-metadata

and import users from the authors.txt file as:

git config svn.authorsfile ~/svn-authors.txt

Step3: Start importing the svn repository

Run the command

git svn fetch

and take a moment to relax, as this process may take a while depending on the size of your repository, if the process stops for any reason you can re-run the command and the process will pick up where you left off.

Step4: Conversion of tags and branches

As SVN does not support real tags like git, so they were imported as branches. To convert them to git tags, run:

for t in `git branch -a | grep 'tags/' | sed s_remotes/origin/tags/__` ; do
git tag $t origin/tags/$t
git branch -d -r origin/tags/$t

As with the tags, you now need to convert the remote branches to local branches and delete the remote branches:

for t in `git branch -r | sed s_origin/__` ; do
git branch $t origin/$t
git branch -D -r origin/$t

Final Step: Remove Unused SVN Data

git config --remove-section svn-remote.svn
git config --remove-section svn
rm -fr .git/svn .git/{logs,}/refs/remotes/svn

Congratulations on successfully migrating from SVN to Git! To make this process even smoother, I’ve compiled a series of shell scripts. You can find them at: https://github.com/ahmedk743/svn-to-git.

Important Notes

  • Always create a backup of your SVN repository before migrating to Git.
  • Carefully review and update authors and commit messages as needed.
  • Be patient during the migration process, as it may take some time depending on the size of your repository. Enjoy your newly migrated Git repository!




Ahmed K.

Software Engineer; Coding while time-traveling through World History!