You are on page 1of 4

Steps for migrating Subversion to TFS

Attach SVN repository to HTTP server


Download the VisualSvnServer from the following site:
http://www.visualsvn.com/server/download/
Implement the following five steps:
1. Install the VisualSvnServer in the local computer selecting HTTP as the protocol and pointing it to the
repositories folder.
2. When the SVN server installs it will automatically execute and display the administration window (it will say
VisualSVN Server on the top of the window); it will also prompt for a user name and password (this might take a
few seconds or a minute). These credentials are needed in order to access any of the repositories.
3. Select the repository to be migrated and right click on the icon and navigate to All Tasks/Manage Security
option. Add the user that was created in the previous step.
4. Right-click again on the repository icon and select the Browse option. This will open your default web browser
and prompt for a user name and password; enter the user name and password created in step #2.
5. Navigate to the section of the repository that needs to be migrated to Git and copy the URL from the address
bar. Save the URL into a text editor, you will need it later on.
Install Git tools on local computer and create Git repository
There are many tools for Git but the one I selected was Git Bash. The download URL is the following:
http://git-scm.com/download/win
Create a text file with user names and email addresses for those users that committed to the SVN repository. Name the
file users.txt. Example of the contents:
User1 = User1 < User1@emailAddress.com>
User2 = User2 < User2@emailAddress.com >
Execute the Git Bash shell and run the following set of commands in the following order where the sections inside the
quotes are to be replaced according to your environment and the quotes removed:
$ cd ~
The above command takes you to your personal folder
$ mkdir [tempDir]
Where [tempDir] is going to be the name for a temporary Git repository
$ cd [tempDir]
Copy the users.txt file into the [tempDir] just created

$ git svn clone --no-metadata -A users.txt [http://website-url/svn/repository/folder/]


Where the URL inside the brackets is the URL for the SVN repository copied in step #5 of the Attach SVN repository to
SVN server section above
$ git svn init [http://website-url/svn/repository/folder/] --no-metadata
$ git svn fetch
This command copies the SVN repository into the Git repository created inside the temporary folder
$ cd ..
$ git clone [tempDir] [directory]
Not sure why the temporary repository needs to be cloned but it seems that there is extra stuff not needed in the
temporary folder that is not transferred into the new folder
$ cd [directory]
Move into the new repository in order to execute the command below
$ gitk
This last command is to view the repository contents with comments. If all went well it should look familiar to those
that have committed to it.
The temporary repository can now be deleted since it is no longer needed.
$ cd ..
$ rm -rf [tempDir]
I mostly followed the directions from this question and answer in stackoverflow.com:
http://stackoverflow.com/questions/79165/how-to-migrate-svn-with-history-to-a-new-git-repository
Copy the local Git repository into TFS
Download and install the most recent version of Git-TF. I installed it using Chocolately from the following location:
http://chocolatey.org/packages/Git-TF
But it is also available in the following location:
http://www.microsoft.com/en-us/download/details.aspx?id=30474
I wish I could say that installation was a breeze but that was not my experience. For some reason I had to manually
modify my environment path by adding the Git-TF and Java folder locations. I suspect that it had something to do with
the way my computer is configured (in a corporate environment with policies and restrictions). At the end I modified
the path environment from a DOS Command prompt using the path=%path%+C:\Git-TF\bin;C:\Java\bin (or something
similar).

Following instructions I found in the internet I was able to initialize my Git repository and configure it to point to the TFS
server with the following commands (from a DOS Command window):
cd [folder with git repository]
Change directory into the git repository folder
git init
Im not 100% sure why I had to do the above step but after many unsuccessful attempts to configure git issuing the init
command made the configure step work
git tf configure [http://sttfs3:8080/tfs/ProjectsCollection] [$/Users/User/repository/project] --deep
Where in the command above the first section inside brackets is the URL for the TFS projects collection and the second
section inside brackets is the local folder with the git project to be imported into TFS. Im not sure what the configure
command does but it appears to me that it creates the bridge between the local git repository and the remote TFS
repository. There were a lot of errors generated during my attempts to save the project to TFS (see the section Errors I
received below) but at the end modifying the config file that is located inside of the .git folder (that in turn is located
inside the projects folder) made it all possible. The section I had to change was the [git-tf server] section. This is was
it ended up looking like:
[git-tf "server"]
collection = http://sttfs3:8080/tfs
serverpath = $/ProjectsCollection/project
Where the right side of the collection variable is the TFS url and the right side of the serverpath variable is the name of
the collection followed by the name of the project.
After modifying and saving the config file the last command issued was the following:
git tf --no-lock checkin
That produced the following message:
Connecting to TFS...
Checking in to $/ ProjectsCollection / project: 100%, done.
Checked in 203 changesets, HEAD is changeset 234
Then connecting to the TFS server showed me a new folder with the contents of my original SVN repository history and
all. Heres a screenshot:

Errors I received:
git-tf: not a git repository (or any of the parent directories): .git
git-tf: A server path must be absolute: $Users/user/directory/project
git-tf: Could not find a valid TFS Collection at http://sttfs3:8080/tfs/ProjectsCollection
git-tf: Could not lock $/Users/user/directory/project
git-tf: specified tfs path '$c:/Users/user/directory/project' is not a valid server path
[git-tf: failed to pend changes to TFS due to the following errors. Please fix the errors and retry check in.TF10175: The
team project folder $/Users does not exist. Contact your Team Foundation Server administrator and ask that it be
created.
TF10175: The team project folder $/Users does not exist. Contact your Team Foundation Server administrator and ask
that it be created.]warning: push.default is unset; its implicit value is changing in [Git 2.0 from 'matching' to 'simple'. To
squelch this messageand maintain the current behavior after the default changes, use: git config --global push.default
matchingTo squelch this message and adopt the new behavior now, use: git config --global push.default simple See 'git
help config' and search for 'push.default' for further information.(the 'simple' mode was introduced in Git 1.7.11. Use
the similar mode'current' instead of 'simple' if you sometimes use older versions of Git)
fatal: 'c:/Users/user/directory/project does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.]
Git-tf websites:
http://gittf.codeplex.com/
https://github.com/git-tfs/git-tfs/tree/master/doc/commands

You might also like