Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Migrating from Subversion to Git

Tags:

git

svn

migration

I have a lot of pre-existing projects and code in a few different Subversion repositories. I am planning on getting my toes wet with Git by migrating a few of the easier/soon to be multi-developer projects to Git. I have a few questions:

  1. If I start with a hosted Git solution, is it hard to change the Git server of a project (In Subversion, you simply have to change the URL, etc)? I would do this to get up and running and comfortable with Git before installing and maintaining my own server locally.

  2. What are some good steps to follow to migrate my data from Subversion to Git? Will I have to check out every revision from SVN, export, and commit to Git to get the history?

  3. Any gotchas that you've experienced?

A few reasons for the change: We do a LOT of branching and merging, we will be adding a few developers on these projects, we will have developers not always in the office/on the network/etc.

like image 734
ashurexm Avatar asked Jun 23 '10 18:06

ashurexm


2 Answers

1. it is actually very easy to change the server since you clone the entire repository on your computer then you just push it to the new server;

2. you can use git-svn to clone the svn repository in a new git repository preserving the history. First you need to create a users file that maps all your SVN users to your GIT users. Make a file on your Desktop named ‘users.txt’. Map the users using this format:

username = Full Name <[email protected]>

Now run these commands:

git-svn init url.to.svn.repository --no-metadata
git config svn.authorsfile ~/Desktop/users.txt
git-svn fetch

The first command initializes the directory as a git-svn hybrid and points the origin at your svn repository. The flag, --no-metadata, tells git to leave all the svn details behind (not the commit log). The next command tells git to remap all the svn users to git users. The last command actually does the fetching.

like image 182
Igor Popov Avatar answered Sep 20 '22 13:09

Igor Popov


firstly I would recommend book Pro Git

  1. It's not difficult at all. You can do something like

    git remote add

and you can have more remotes at the same time and fetch changes from your coworkers to different branches before you merge them and push to the server.

  1. I have no experiences with more branches in svn but for me was enough to do something like

    git svn clone svn-repo

like image 40
pejuko Avatar answered Sep 17 '22 13:09

pejuko