Skip to content
Tutorials

Migrating from TFS to Git: How to Run CodeScene on TFS Projects

What if your projects are under version control in Microsoft's Team Foundation Server.

CodeScene blog - read insights from CodeScene.

The CodeScene analysis engine runs on git repositories. 

 

What if your projects are under version control in Microsoft’s Team Foundation Server (TFS), and you still want to use CodeScene? No problem, you can use git-tfs to convert your TFS projects to git repositories.

This guide assumes you are running Windows 10 (it might work with 7 and 8, as well).

Migrating from TFS to Git: How to run CodeScene on TFS Projects.

 


Install the Prerequisites

First, install Chocolatey on the computer you want to use for the conversion. Follow the instructions at chocolatey.org/install. Note that you need PowerShell 3, or higher, and that you need to run it as administrator.

After Chocolatey is installed, run the following command in PowerShell. You should be asked to confirm the installation scripts. Note that this command will also try to install git, if not previously installed. If already installed manually, it seems that it logs errors, but continues with gittfs nonetheless.

choco install gittfs


Next, make sure you now have git and git-tfs available on your PATH:

git tfs help
# prints available commands

 

If not available, you might have to set the PATH for the session, or restart PowerShell.

 

Converting TFS Projects for CodeScene Analysis

Let’s say that you want to clone the repository path called “Development”, where you integrate changes in your development workflow, in a project collection called “MyCollection”. The “Development” path is probably the one you want as a branch in Git to analyze in CodeScene.

Run git-tfs with the following command in PowerShell to convert and clone the TFS repository to a git repository in the directory MyProject.

git tfs clone --export http://tfs:8080/tfs/MyCollection $/MyProject/Development MyProject

 

Note the --export flag used in the cloning command. This tells git-tfs to include metadata, such as information about work items, in each commit message. This can be used in CodeScene to link commits by Ticket ID and to measure temporal coupling across commits, and across repositories.

 

Verifying the Git History

The clone operation explained above can take a lot of time, so it can be useful to try cloning a small repository first, and verify the resulting git history. You can also clone from a specific changeset, saving some time, and use that to verify the git history:

git tfs clone --export --changeset=1337 http://tfs:8080/tfs/MyCollection $/MyProject/Development MyProject
cd MyProject
git log
# should include work item IDs in commit messages, e.g. [1337] ...

 

Note that the --export flag does not seem to be supported by the quick-clone command.

 

Work Item and Ticket ID Mapping

When using your converted git repositories in CodeScene, a Ticket ID pattern
like \[(\d+)\] should capture the exported work item metadata in your commit messages.

 

Need Help?

Leave a comment below, or contact us

Adam Tornhill

Adam Tornhill

Adam Tornhill is a programmer who combines degrees in engineering and psychology. He’s the founder and CTO of CodeScene where he designs tools for code analysis. Adam is also a recognized international speaker and the author of multiple technical books, including the best selling Your Code as a Crime Scene and Software Design X-Rays. Adam’s other interests include modern history, music, retro computing, and martial arts.

Elements Image

Subscribe to our newsletter

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Semper neque enim rhoncus vestibulum at maecenas. Ut sociis dignissim.

Latest Articles

AI Coding Assistants: Introducing CodeScene AI Generated Code Refactoring

AI Coding Assistants: Introducing CodeScene AI Generated Code Refactoring

AI Coding Assistants: Let's introduce you to AI generated code refactoring. Read more and join the Beta testing program.

Change coupling: visualize the cost of change

Change coupling: visualize the cost of change

Code can be hard to understand due to excess accidental complexity. Or, it can look simple, yet its behavior is anything but due to complex...

CodeScene's IDE Extension brings CodeHealth™ Analysis directly into your editor

CodeScene's IDE Extension brings CodeHealth™ Analysis directly into your...

We've just launched an IDE Extension for VS Code, helping developers tackle code complexity within the editor. Read more and try it out!