Migrate source code from one repo (tfs or other) to new GIT repo

Hello everyone,

This is a quick topic today, probably not really new either.
Anyway... For a client, I had to migrate the source code from an old TFS 2010 to VSTS.

When I got the news, I directly dug the internet to find out :

How to do that properly and keep the history of everything ?

In fact, the usage of that lib : git-tfs and few command lines and you are done with that task.

# clone the whole repository (wait for a while...) :
git tfs clone http://tfs:8080/tfs/DefaultCollection $/name_of_old_repo  
cd <name_of_old_repo>  
git remote add new-origin <url_of_new_repo>  
git push new-origin --mirror  

If you are already on a git and you want to migrate to another git repo, simply use :

git clone --mirror <url_of_old_repo>  
cd <name_of_old_repo>  
git remote add new-origin <url_of_new_repo>  
git push new-origin --mirror  

And tada !

Hope this will help.

Clement

Dynamics 365 CRM & Power Platform addict.