Click here to Skip to main content
15,885,244 members
Articles / Hosted Services / Azure

Migrating your Old TFVC Repository to Git with Full History in Azure DevOps

Rate me:
Please Sign up or sign in to vote.
4.00/5 (1 vote)
15 Mar 2021Ms-PL3 min read 15K   6   4
How to migrate your old repositories in TFVC to Git with full history
In this post, I will explain two ways in which you can migrate your old repositories in TFVC to Git while keeping the history of the check-ins/commits.

There might be many reasons for you or your organization to migrate your old repositories in TFVC to Git and you would like to keep the history of the check-ins/commits. Here, I will explain two ways of achieving this.

  1. Migrating using git-tfs, with this, you can migrate with full history and it is a little complex process.
  2. Migrating using Import repository wizard in Azure DevOps. With this, you can migrate with 180 days history and it is a very simple process.

In my case, I had to choose option 1 as my project was older than 4 years and I wanted to get the history for it.

image

1. Migrating using git-tfs

Get git-tfs by following the instructions mentioned at git-tfs/README.md, I installed it through Chocolatey which I already had installed, chocolatey is a nice and easy way to install and upgrade software/programs/packages on Windows, do check it out if you haven't used it yet, it is a package manager for windows.

  1. Run cmd as administrator
  2. Install git-tfs by running choco install gittfs
  3. Verify if git-tfs is installed correctly by running git-tfs --version
  4. You should see its version information like below:
    C:\WINDOWS\system32>git-tfs --version
    Found matching Visual Studio version at 
    C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional
    git-tfs version 0.32.0.0 (TFS client library 16.0.0.0 (MS)) (64-bit)
    
    Note: If you want to force git-tfs to use another version of the tfs client library,
    set the environment variable `GIT_TFS_CLIENT` 
    with the wished version (ie: '2015' for Visual Studio 2015,...)
    Supported version: 2019, 2017, 2015
  5. Run the command git tfs clone [URL] [TFVS_Project] “[Local_Git_folder]” after changing placeholder values of URL, TFVS_Project, Local_Git_folder. In my case, it was like below:
    C:\WINDOWS\system32>git tfs clone 
    https://arunendapally.visualstudio.com/defaultcollection/ $/donna-bot 
    "C:\Arun\Project\donna-bot-new"
    and after you hit the Enter key, it will prompt you to login:

    image

  6. This process will take a while to get everything cloned into the local git folder location you mentioned while running the command. You should see something like below:

    image

  7. If you open the location in explorer, you should see files cloned like below:

    image

  8. If you want to see the git logs, you can run this command git log --all --oneline --decorate --graph and you would see something like below:

    image

  9. Now you can open that folder in VS Code, clean-up any files you don't need, and add .gitignore for the files you want to exclude in the commit.
  10. Now set the git origin to the repository where you want to commit and push this project. You can run the below command replacing your git origin URL.
    git remote add origin 
    https://arunendapally.visualstudio.com/DefaultCollection/donna-bot/_git/donna-bot-new
    git push -u origin --all
  11. After running it, I pushed all my changes to my remote with complete history:

    image

  12. I hope you guys successfully migrated from TFVC to Git without any problem. If you are stuck, you can reach out to me by leaving a comment below. I can try to help.

2. Migrating using Import Repository Wizard in Azure DevOps

You can choose this option when you do not really care about the history greater than 180 days, and of course, if you are not deleting the old TFVC repo, you can always get back to see the history.

As this is a simple approach, you can simply follow these instructions Import repositories from TFVC to Git - Azure Repos | Microsoft Docs and you would be able to migrate from TFVC to Git repo with 180 days history.

That's it! Please share this post with your friends and colleagues if you liked it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


Written By
Architect Thomson Reuters
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionError when cloning the TFS Repository for using git tfs clone Pin
Member 137717974-Jan-23 19:58
Member 137717974-Jan-23 19:58 
Questiongit tfs clone [URL] [TFVS_Project] “[Local_Git_folder]” Pin
Rana Zain 202120-Sep-21 7:57
Rana Zain 202120-Sep-21 7:57 
QuestionGreat tutorial - question on login params ... Pin
Thomas Byrne 202119-Aug-21 6:37
Thomas Byrne 202119-Aug-21 6:37 
AnswerRe: Great tutorial - question on login params ... Pin
Arun Endapally7-Sep-21 2:54
professionalArun Endapally7-Sep-21 2:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.