Cover image showing the process of migrating an SVN repository’s trunk, branches, and tags to Git using git svn clone

Overview

This article explains how to assemble the git svn clone command when moving an SVN repository to Git.

Who should read this

  • Developers who still run SVN but need a gradual move to Git
  • Developers who must map SVN trunk, branches, and tags onto Git branches and tags

Installing Git

Does Git automatically provide git svn?

Not always.

Some Git packages are shipped without git svn.

Check immediately after installing

1git svn --version

Installing git svn when it is missing

  • Windows: If Git for Windows is installed but git svn is missing, reinstall and make sure the Git SVN component is included.
  • macOS: Use Homebrew to install git-svn separately.

SVN → Git

Core command

1git svn clone [svn path] --authors-file=[authors path] -s [git-directory]

Option reference

svn path

Provide the root URL of the SVN repository.

Example:

1https://svn.example.com/repos/my-project

Option –authors-file=[authors path]

This file maps SVN author strings to Git commit author format.

Without it, author info may be wrong or the migration will show warnings.

The authors file typically looks like this:

1svnUser1 = Hong Gil-dong <[email protected]>
2svnUser2 = Son Woncheol <[email protected]>

How you gather the author list depends on your environment; most teams extract it from SVN logs.

Option -s

-s is shorthand for --stdlayout.

Use it when the SVN repository follows the standard layout.

The standard layout contains:

  • trunk
  • branches
  • tags

With -s, git svn treats the directories as follows:

  • trunk → default branch history
  • branches → remote branches
  • tags → tags

If the SVN repo is not standard, omit -s and explicitly set the paths:

1git svn clone [svn path] --authors-file=[authors path] \
2  --trunk=TrunkDir --branches=BranchesDir --tags=TagsDir \
3  [git-directory]

Option git-directory

The local path where the converted Git repository will be created.

If it does not exist, the directory is created before cloning.

Example run

1git svn clone https://svn.example.com/repos/my-project \
2  --authors-file=./authors.txt \
3  -s \
4  my-project-git

What to verify after migration

Check branches

1cd my-project-git
2git branch -a

A remotes namespace appears that mirrors the SVN branches.

Check tags

1git tag

SVN tags should now exist as Git tags.

Notes

Author mapping

Respect the author file format.

1# {svn id} = {git_user_name} <git_user_email>
2svnUser1 = Hong Gil-dong <[email protected]>

Cloning takes too long

The entire SVN history is copied, so repositories with many revisions will take time.

Before you run the command, review:

  • Network latency
  • SVN server performance
  • Revision range: consider options that start from a specific revision if needed.
  • Sleep/hibernation: keep desktop machines awake while the command runs.

SVN branch names look odd in Git

git svn places SVN branches under the remotes namespace.

After migration, create local Git branches from the ones you need and tidy up the names.

Wrapping up

If your SVN repository follows the standard layout,

git svn clone ... -s migrates trunk, branches, and tags in one shot.

With an accurate authors mapping,

you can bring over commit authorship without pain.