Migrate SVN to Git

Overview

This article walks you through migrating your DreamHost SVN repository to Git.

This article assumes that you have previously created a Subversion repository in your DreamHost panel which is still accessible on the Subversion page.

Install a local version of git

DreamHost's version of git is not able to run the git svn command. In order to use this command, you must first install a local version of git. View the following article for instructions:

Once installed, you are able to run the commands below to migrate your svn repository.

Clone the SVN repository

Log into your website via SSH for the domain the SVN repo was configured on. Then navigate into your user's home directory.

[server]$ cd ~

You should see the svn directory listed here. For example:

[server]$ ls -la ~ | grep svn
drwxr-xr-x  3 myuser pg1234567      78 Nov 18  2020 svn

Non-standard repository layouts

If your repository layout is simple or does not follow the standard svn layout containing the trunk/, branches/, and tags/ directories, you can run the following commands.

  1. Create a new directory to clone your SVN repository into.
    [server]$ mkdir svn-cloned
  2. Change into this new directory.
    [server]$ cd svn-cloned
  3. Run the git svn clone command to clone the repository into this directory.
    [server]$ git svn clone https://example.com/svnreponame/
    This command creates a new directory named the same as your SVN repository.
  4. Change into this directory.
    [server]$ cd svnreponame
  5. Run git log to view all commits.
    [server]$ git log

You can now use git commands to manage this new git repository.

Standard SVN repositories

If your repository is configured with the standard svn layout, run the following command to clone the svn repo into a new git repository. You can name the new git repository anything you like.

[server]$ git svn clone https://example.com/svnreponame/ --stdlayout --prefix=origin/ newgitrepoName -s

When you run the command above, a new directory is created for your new Git repository.

You can now use git commands to manage this new git repository.

Additional info

The commands above use the git svn clone command. This both initializes a new git repository while fetching the commits from your svn repository.

For more control over what is migrated, you could also choose to run git svn init if you'd like to initialize a repository while specifying subfolders, like a specific branch. Once created, you would then run git svn fetch import the code.

View the following link for more information on available options and their settings:

See also

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?