SVN to Git migration that works

SVN to Git migrationSVN to Git migration is mostly about the following things:

  1. Migration of all branches and tags
  2. Saving complete history of changes
  3. Inheritance of commit author names

Fortunately there is an easy way to accomplish SVN to Git migration using git svn tool that comes as part of Git installation. This tutorial describes the entire process step by step.

Prerequisites

Latest stable version of Git client require to be installed in your system. If your OS is Windows I would  recommended using Bash Git console.

Initialize new repository for SVN to Git migration

First of all we need to prepare new empty Git repository in your preferred directory.

Here we are initializing Git repository with standard SVN  directory structure (trunk, branches and tags). Additional SVN to Git migration related meta is created (including your SVN repository URL). Prefix svn/ is specified in order to separate remote SVN branches and tags from local (native) git branches and tags.

Fetch entire SVN repository

Depending on how big your SVN repository is it can take a while  to fetch it .

Technically the import can be considered done at that stage as everything is now in your new local Git repository. Let’s take a look what do we have there.

This command displays all local (Git) branches and remote (SVN) branches and tags.

Turn remote SVN branches to local ones

At that step we are about to create new git branches and tags from remote SVN branches and tags. This can be accomplished using standard git branch and git tag commands.

This process can be automated easily with a simple Bash script.

Let’s check the result of these operations.

As you can see now we have both old SVN and new Git branches and tags in the same Git repository.

Push all changes to remote Git repository

This is the last step of our SVN to Git migration exercise and everything is ready to be pushed to remote Git repository. First you need to tell Git where your remote repository is.

Then you can push all branches and tags. For some reason there is no single operation for this.

That’s pretty much all. SVN to Git migration is done! Now I would recommend to check remote repository content and clone it to another local directory. If everything looks fine you can safely abandon your temporary migration repository.

 SVN to Git migration is done. What’s next?

Note that all commit authors where migrated to Git repository as well. The only problem is that SVN user emails are not sent with SVN commits and Git generated random strings where emails where missing.

To fix this for future commits make sure all project members:

  1. Define the same username as they had in SVN
  2. Provide valid email

Happy commits!

If you are still looking for a good Git repository hosting provider check out comparison chart for best offers.

SVN to Git migration references

Leave a Reply

SVN and GIT HOSTING

Source repository hosting

FAQ

BLOG POSTS

HOT OFFERS