Migrating from SVN to GIT with Branches and Tags

I needed to convert a number of small subversion repositories to git so that they could be hosted publicly on GitHub and some hosted on our private GitLab service. I am adding a few notes here of what I did to help my future self. If it helps anyone else – bonus.


In an empty test directory initialise a git repository with the URL to your svn source:

Check the settings are correct with:


If you want to have valid git authors corresponding to your SVN users then create an authors file in the following format:

The word on the left of the equals sign is the svn username. On the right is the corresponding info to use within git. If you already have a copy of the svn repo locally you can run the following code to help generate a file of svn usernames as a starting point:

If you need to checkout the svn code you would first need to:

Get the Subversion Code

The next step was to fetch the code from the SVN repository (the URL was already initialised above with git svn init) and I have specified my authors-transform.txt file to give git identities to the svn usernames:

At this point you should see all your code.  If no files come down consider removing the .git directory and run the ‘git svn init’ command again but omitting the –stdlayout option. I ran the following to have a look at all (-a) the local and remote branches:


git branchConverting Branches

There was shell scripts on some of the other articles I read to convert svn branches to git branches:

However that code did not work for me. I think it was related to the naming used in my SVN repo (see image above) as the word branch was not there. So I manually converted the branches as follows:

I read that as, create a local git branch named BRYCE using the code from the remote SVN branch at remotes/svn/BRYCE.

Converting Tags

Since the command git branch -r was showing the SVN tags with ‘tag’ in the name I was able to use the following shell to convert:

Pushing to GitLab or Github

After creating a new project on Gitlab/Github to house your code use the address to add a new remote origin:

Then push the code up to that git remote repository:

Browsing to the web interface I was able to see the code complete with the branches and tags:

GitLab Branch References:

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">