Migrating from Subversion to Git

I've been helping a company move its source code from Subversion to Git recently to support their Agile transition. They're moving their build, issue tracking and code repos to Visual Studio Team Services (VSTS). This is the cloud-hosted version of Microsoft's Team Foundation Services, with built in Git hosting, build tasks and a Jira-like issue tracking system. I really like it, plus it's free for teams of 5 or less, making it perfect for my development needs at home. Check it out at VisualStudio.com

 Most of my customer's projects don't need to keep their Subversion history - unfortunately they had no policy for commenting commits and most check-ins have empty messages so aren't of much use. The teams have made a conscious decision to abandon the past and drop the history. We will keep the old SVN repos alive for a while so if we really need to we can look back at changes, but don't expect to use it much. The simplest way to migrate these projects is to export them and add them as a new Git repo.

svn export http://svn.example.com/subversion/ ↩
    Project/trunk/ Project

A    Project
A    Project\src
A    Project\src\MyFile.java
Exported revision 18.

 Now over in VSTS you can make a new project, or add a repository to an existing project and push the code up:

 

VSTS prompts you for the new repo name, and lets you add a default .gitignore file for the project's language:


Then you can go back to the command line and associate your code with the new VSTS repository.  First off, initialize Git so that your project can be checked in:
git init 

 Initialized empty Git repository in C:/tmp/export/Project/.git/

Then you will add a Remote to your repository, telling it about the VSTS Git server so you can share your code with other people.
git remote add ↩
     origin https://x.visualstudio.com/GitDemo/_git/FreshRepo

The URL for your new repo can be found by clicking on the Clone button in VSTS.  Now you want to pull down the master branch, and track it so that you are working on it:
git pull origin master

 remote:
 remote:                    vSTs
 remote:                  vSTSVSTSv
 remote:                vSTSVSTSVST
 remote: VSTS         vSTSVSTSVSTSV
 remote: VSTSVS     vSTSVSTSV STSVS
 remote: VSTSVSTSvsTSVSTSVS   TSVST
 remote: VS  tSVSTSVSTSv      STSVS
 remote: VS   tSVSTSVST       SVSTS
 remote: VS tSVSTSVSTSVSts    VSTSV
 remote: VSTSVST    SVSTSVSTs VSTSV
 remote: VSTSv        STSVSTSVSTSVS
 remote:                VSTSVSTSVST
 remote:                  VSTSVSTs
 remote:                    VSTs    (TM)
 remote:
 remote:  Microsoft (R) Visual Studio (R) Team Services
 remote:
 Unpacking objects: 100% (3/3), done.
 From https://x.visualstudio.com/GitDemo/_git/FreshRepo
  * branch            master     -> FETCH_HEAD
  * [new branch]      master     -> origin/master

You are now able to commit your code and push up to the new repository.  Next time I will cover how to keep your branches in Git.

Comments

Popular posts from this blog

Setting VSTS variables from PowerShell

Feature Toggles on a .Net Core API

Feature Toggles for Angular UIs