Skip to content

Instantly share code, notes, and snippets.

@pajtai
Created October 12, 2012 16:12
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save pajtai/3880014 to your computer and use it in GitHub Desktop.
Save pajtai/3880014 to your computer and use it in GitHub Desktop.
3 steps for migrating from SVN to GIT

3 steps for migrating from SVN to GIT

assuming password protected svn repo with standard trunk, branches, tags setup

Step 1

svn2git http://svn.example.com/path/to/repo --username [USERNAME] --verbose

After installing nirvdrum's fantastic svn2git (a fork of jcoglan's svn2git)

The verbose option is essential for password input

Now you have a pretty .git that has the branches and tags as you would expect. Double check:

# check branches
git branch
# check tags
git tag

The above would not look as you would expect with a simple git svn clone without the svn2git script.

There are 2 more things to do (assuming you a working with a central git repo (e.g. GitHub or a GitLab install))

Step 2

First add your remote (for example):

git remote add [REMOTE-NAME] git@[URL]:[PROJECT].git

(you can make up [REMOTE-NAME] (e.g. "github"). you have to get [PROJECT] from that central git repo)

Step 3

Now push all - including branches and tags - to it

git push [REMOTE-NAME] --mirror

And that's it!

Full migration of an SVN repo and pushing the new GIT repo onto a central git so that all svn branches and tags show up as you would intuitively expect them to in GIT. (without svn2git you get all the branches and tags, but they would be difficult to find)


PS, now you can pull in new changes from svn with

svn2git --rebase

Make sure you have the svn repo in your .git/config still

Also, make sure all new tags have been added, if not:

git show svn/tags/[TAG-NAME]
# from the above get the commit ref and log

git tag -a -m "[LOG MESSAGE]" [COMMIT REF] [TAG-NAME]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment