Migrate from SVN to GIT with history

January 1, 2011
 by 

Recently we decided to switch from SVN to GIT at my new gig. There is a plethora of information on the web regrading git-svn hybrids, running them in parallel, etc but thats not what we want. We wanted to just cleanly migrate from SVN keeping all the history and deprecate the old SVN repo. The best info I found was Jon Maddox’s fix but that didnt work entirely so here is the summary of how it all works in a few simple steps.

1
2
cd ~/Desktop
vim users.txt

Insert a list of your users as shown below. If you forget any the fetch will fail but dont worry, the error will contain the missing email address.

johnclarkemills = John Clarke Mills <john@gmail.com>
somedude = Some Dude <dude@gmail.com>

Here comes the fun part:

1
2
3
4
5
6
7
mkdir my_blog_tmp
cd my_blog_tmp
git svn init http://svn.location.com/trunk/ --no-metadata
git config svn.authorsfile ~/Desktop/users.txt
git svn fetch
cd ..
git clone my_blog_tmp my_blog

Now the final step. Your repo is all setup locally, but it isnt linked to any remote GIT repo. Here is the final step that got me all setup.

1
2
cd my_blog
vim .git/config

Now all you have to do is replace the urls in there with your git repo’s url like so: john@git.location.com:my_blog.git. Save the file, and now your all set, history included!

1
2
git pull
git push origin master

Categories: Computers, Software


8 Comments

  1. [...] Спасительная статья про миграцию с SVN в GIT с сохранением истории: http://www.johnclarkemills.com/2011/01/01/migrate-from-svn-to-git-with-history/ [...]

  2. Gennady Agranovich says:

    what if my svn server is not up-and-running? Can I still migrate all svn history into GIT?

  3. Simon Potter says:

    Brilliant, thanks that worked exactly as expected cheers

  4. Jay Khimani says:

    Thanks John for nice and concise guide. I was just wondering if there is a way to tell git svn fetch to fetch history till particular revision or date? As I’ve a 5 year old multi module maven project in SVN which I want to migrate to GIT. Now you can imagine how long it will take to generate the snapshot for each commit in last 5 years.

  5. jaswinder says:

    it is possible using git svn fetch -r

  6. Jay Khimani says:

    Sorry for late reply/acknowledgment. Finally I ended up using subgit which is way faster and I managed to migrate complete 5yrs history to git overnight.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Copyright © 2005-2011 John Clarke Mills

Wordpress theme is open source and available on github.