Skip to content

Instantly share code, notes, and snippets.

@robandpdx
Last active October 24, 2022 22:35
Show Gist options
  • Save robandpdx/a2a976c713b3e482b9be50a9104489d7 to your computer and use it in GitHub Desktop.
Save robandpdx/a2a976c713b3e482b9be50a9104489d7 to your computer and use it in GitHub Desktop.
Moving an SVN monorepo to git

Moving an SVN monorepo to git

git svn expects your repo to be in the following structure...

./bigsvn
├── branches
│   ├── project1
│   └── project3
├── tags
│   └── project2
└── trunk
    ├── project1
    ├── project2
    └── project3

However, we often find that the svn monorepo is in the following structure...

./bigsvn
├── project1
│   ├── branches
│   ├── tags
│   └── trunk
├── project2
│   ├── branches
│   ├── tags
│   └── trunk
└── project3
    ├── branches
    ├── tags
    └── trunk

This poses a challenge when migrating to git. Below are three options to deal with this issue.

Break up the monorepo

Since the users a likely checking out each project seperately, you might want to simply break up the monorepo into several git repos. This is the simplest solution and the one that I recommend. I'm not a fan of monorepos at all. Don't get me started 😬.

Convert each part of the monorepo to a git repo using git svn. Follow these instructions to convert from svn to git.

Convert svn repos to git, then merge git repos

Convert each part of the monorepo to a git repo using git svn. Follow these instructions to convert from svn to git.

Then use git subtree to combine the various git repos into one. Follow these instructions to combine the git repos.

Rearranging the svn repo

Rearrange the monorepo into the structure that git svn expects. You want the final structure to look like this...

./bigsvn
├── branches
│   ├── project1
│   └── project3
├── tags
│   └── project2
└── trunk
    ├── project1
    ├── project2
    └── project3

⚠️ NOTE: After much testing, I have found there is no way to rearrange the monorepo into the new structure AND preserve history.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment