InCycle Software's Application Modernization and DevOps Blog

How easy it’s to migrate SVN to TFS 2013 (Git Repo)

Written by Sahas Subramanian | Aug 8, 2013 2:24:07 AM

If you wonder what's happening with Git & TFS combination, spend a few minutes here

http://incycle-corpweb.azurewebsites.net/2013/08/git-in-visual-studio-alm-world/

http://incycle-corpweb.azurewebsites.net/2013/08/version-control-with-tfs-2013-git-repository/

In VS 2013, we have the ability to create Team Projects with Git repo to version control the code..here is a quick walkthrough showing how to migrate your code from SVN to TFS (Git Repo)

Why did I choose SVN – TFS Integration Platform does a pretty good job to migrate sources and work items from Clear Case and Clear Quest respectively. However, they didn't invest enough to expand that initiative and specifically, we see the willingness to move from SVN and unfortunately there is no easy way. There are some 3rd party tools but you got to pay J. But Git Repo makes it much easier. I know SVN à Git migration or Local Git repos with SVN centralized repo is not something new but gets more importance as Git joins VS ALM family.

So, I take one of the open source repository teach-me from google code http://teach-me.googlecode.com/svn. This is fairly small Repo has about 270 changes between 2009 and today.

On my laptop, I got Git installed with Git bash.

Initialize new Git Repo

 

I created a local folder called teach-me and currently on that path.

I'm using git svn to the most part

Command:

git svn init http://teach-me.googlecode.com/svn/trunk/ --no-metadata

Output:

Initialized empty Git repository in c:/Users/Sahaswaranamam/Source/Repos/teach-me/.git/

Fetch SVN Repo

 

Run the below command to fetch the repository.

Command:

git svn fetch

Output:

 

Above, I want to fetch all the revisions from SVN.

If you want to fetch portion of the code, you might use below command (change the revision accordingly)

git svn fetch –r revision:HEAD

Once this process is over, if you run git log, you should see all the commits in local Git

 

Create TFS Team Project with Git Repo

 

Now, Git repository is available in my local disk with all the history data from SVN.

On the right side, I want to create a new TFS Team Project with Git as the centralized repository

(Though, I'm using TFSService, you should be able to create the same from TFS 2013 PRev)

 

Git Remote

Now, we have another centralized Git repository ready and inorder to push/pull code between these repositories, we just need to add the alias

Command:

git remote add TfsGit https://sahas.visualstudio.com/DefaultCollection/_git/teach-me

 

Push the code to centralized Git Repo

 

Now, we are ready to push the code from local Git repository to Remote Git repository and hence all the team members can consume from the centralized Git repository

Command:

git push TfsGit master

Output:

$ git push TfsGit master

Username for 'https://sahas.visualstudio.com': sahas

Password for 'https://sahas@sahas.visualstudio.com':

Counting objects: 3424, done.

Delta compression using up to 4 threads.

Compressing objects: 100% (3407/3407), done.

Writing objects: 100% (3424/3424), 3.65 MiB | 527.00 KiB/s, done.

Total 3424 (delta 2751), reused 0 (delta 0)

remote: Analyzing objects (3424/3424) (8066 ms)

remote: Storing pack file and index... done (626 ms)

To https://sahas.visualstudio.com/DefaultCollection/teach-me/_git/master

* [new branch] master -> master

We are done..navigate to TFS web access and look at the history on the server repository

 


 


 

 

 

 

 

 

 

 

 

On a normal laptop this entire process took about 20 mins..

Thanks for reading and stay tuned to see how to migrate SVN-->TFS Version Control