Migrate from SVN to GIT with history
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
[...] СпаÑÐ¸Ñ‚ÐµÐ»ÑŒÐ½Ð°Ñ ÑÑ‚Ð°Ñ‚ÑŒÑ Ð¿Ñ€Ð¾ миграцию Ñ SVN в GIT Ñ Ñохранением иÑтории: http://www.johnclarkemills.com/2011/01/01/migrate-from-svn-to-git-with-history/ [...]
Thanks indeed!
what if my svn server is not up-and-running? Can I still migrate all svn history into GIT?
Brilliant, thanks that worked exactly as expected cheers
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.Jay, I can’t recall. I did this so long ago and I haven’t gone back to SVN since! Best of luck!
it is possible using git svn fetch -r
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.