Migrate TFS to GIT with check-in history

Pankaj D Sonawane
4 min readMar 26, 2021

--

Migration is nature

This post is about two popular Source Control Systems, TFS (Team Foundation Server) and Git. Each of one is strong and has many users in their respective world.

After using TFS for many years, if someone reads Dennis Doomen’s post about ‘Why you should abandon TFS and adopt Git’, a keen developer would definitely like to taste Git.

First question appears in mind, how would I take my work from TFS to Git.
One would simply copy code to Git local directory and push it to remote repository. Such simple approach has unacceptable drawback — you would totally lose your footprint of check-in history!!

This post will guide you step by step, how you would take your code from TFS to Git with check-in history.

We are going to use “Git TFS”, which is a two-way bridge between TFS and Git. It fetches TFS check-ins into Git repository and lets you push your updates back to TFS. However, this post is all about to disconnect your code from TFS and connect to Git remote repository.

Implementation Steps

  1. Setup & Installations
  2. Migration: TFS to Git
  3. Refer remote Git repository
  4. Verify Code & Check-in History

1. Setup & Installations

a. Install “Git”
https://git-scm.com/download/win
Download “64-bit Git for Windows Setup.”
Git version used: Git-2.31.0–64-bit

Install Git

b. Install “Git TFS”
Download latest package of “Git TFS” from
https://github.com/git-tfs/git-tfs/releases

Extract the folder “GitTfs-0.32.0” at C:\Program Files\

Extracted Git-TFS

Make sure “Git TFS” path is added to System Path Variables. If not, refer below steps:

Set Environment Variable for Git-TFS

Reopen terminal in administrative privilege and run below command to make sure “Git TFS” is set appropriately.
>> git tfs help

Command Git-TFS

2. Migration: TFS to Git

In this section, we are going to clone repository from TFS.

a. Create a directory, where TFS code to be migrated.

b. Open terminal in administrative privilege and browse to newly created directory in terminal.

c. Formulate command in below format and run in terminal.
>> git tfs clone %TFS Project URL% “%TFS Relative Project Folder Path%”

Note: Make sure the “TFS Relative Project Folder Path” is prefixed with $

Command would form something like below:
>> git tfs clone https://tfs-XXXX.com/XXX “$/YYYYY/YY”

Git-TFS Clone

3. Refer remote Git repository

In this section, we are going to push code in Git repository.
As of now the git repository is connected remotely to TFS. We have to manually remove TFS connection & modify the connection to point to remote Git Repository.
a. Open “config” file from directory “.git”, of newly created repository directory.

b. Remove all sections from the config file, except section [core]
config file would look like, as shown below:

Git config file

c. Open terminal in administrative privilege and browse to repository directory.
Run below command to connect the local repository with remote repository.
>> git remote add origin %Git Remote Repository URL%

To push code to remote Git repository, run below command
>> git push -u origin --all

If you get error in above command, try below command
>> git push -u -f origin --all

4. Verify Code & Check-in History

Open the project in Visual Studio and check Git History of any file. You should be able to see list of check-ins history.

Thank you for reading. If you like this post, give a Cheer!!!
Happy Giting

--

--

Pankaj D Sonawane

Enthusiastic Full-Stack Developer | Java | Dot Net | Angular | CSS