Skip to content

TFS-VC to GIT migration

Overview

Git is an open source version control system for tracking changes on files and coordinating work on those files within the team. Git is faster and more powerful than TFVC.

Why Git is better

  1. Feature Branching Model
    • Git associates a branch with every new feature, unlike TFVC where every branch is a copy of entire project.
    • Git branches are lightweight as Git stores a branch as a reference to a commit, as compared to TFVC where branches are entire copy of the directory.
    • This ensures better collaboration between team members working on the same feature. Members can all point to the same branch. Also, simultaneous development in own branches increases productivity.
    • Git allows any number of local commits to the feature branches, without interfering the work associated with other features.
    • Changes are merged to the develop/main branch after all the members have committed their change and the feature is tested and the pull request is approved. Main branch always contains stable and high-quality code.
  2. Distributed Version Control System (DCVS)
    • Git allows working offline, completely disconnected from the central hosting server by cloning repository to the local machine, unlike TFVC where each check-in is pushing code to the central hosting server. The downside to a dedicated server approach is that when the server is down, no clients can access the code.
    • Local commits need to be pushed/synced to the central server only when changes are tested and approved, unlike TFVC where a check-in of non-tested code can adversely affect the existing functionalities.
  3. Better Review Process
    • Git supports “Pull Requests” to request feedback from the reviewers. The improvements made based on the feedback can be committed to the same branch, which appears as part of the same pull request. Reviewers can review only the latest additions which can be identified by commits.
    • In TFVC, each review request is independent of the other, forcing reviewers to review the complete shelveset each time, where some files could be just class/method renaming.
  4. Faster Switching between branches.
    • In TFVC there is no simple way to save the state of your changes like file additions, modifications, file deletions and switch to another state of code. For example, to work on two features and switch back and forth.
    • In Git, you simply checkout a different branch.
  5. Better Tooling Support
    • Git has a wide variety of plug-ins for IDEs.
    • Wide variety of tools with good GUI have integrated Git.

Why Projects should first convert to Git before AZDO migration

  1. Git’s design and performance are remarkably good among all the distributed version control system (DCVS) tools. Git can move work quickly between servers without losing work.
  2. Git makes cloud hosting easier. There are many Git hosting services that are fail-safe and may also provide a frond-end for making common source control operations easy and convenient.
  3. Mobility - Git repository is simply a folder, easily movable within a system or to another system / platform.

Getting Started / Basic Git Commands and usage

Basic Git Terminologies 1. Main - previously known as Master: the repository’s main branch. Depending on the workflow, it is where all the stable and approved work appears or where the integration happens. 2. Clone: copies an existing Git repository, from the remote location to the local environment. 3. Commit: posting files to the repository (locally); in TFVC it is referred to as “check-in.” 4. Fetch and Pull: also known as “update” or “get latest” in other version control systems. The variance between fetch and pull is that pull combines both fetching the latest code from a remote repo and performing the merging. 5. Push: submitting the code to a remote repository. 6. Branch: A branch in Git is a pointer to a commit. It is not a physical copy of the files as in other popular version control systems. 7. Merge: joining two or more commit histories. 8. Workspace: the colloquial name for the local copy of a Git repository. 9. Staged Changes: These changes are tracked by git in version control. Once we mark these changes as staged, they will become part of commit, when the commit operation is executed. The files which we do not want to be added to the repo can be kept un-staged. 10. Origin: the default name for a remote repository. 11. Local Repository: copy of a Git repository on the personal workstation 12. Remote Repository: a secondary copy of a Git repository where you push changes for collaboration or backup 13. Upstream Repository: the colloquial term for a remote repository that you track 14. Pull Request: to let others know about changes you've pushed to a branch in a repository

  • To get started with Git and know the Git basic commands refer the doc here
  • To know more on Git and get familiarized with Git commands refer the Microsoft doc here.
  • A great tool to learn the concepts of git is git-school.

How to convert a repo to Git?

When the code resides on a centralized version control (TFVC) in Team Foundation Server, migration can be done in two different ways - 1. Tip/labeled Migration – This method of migration can be used requirement satisfies the following conditions. - When only the latest version of the source code needs to be migrated - Migrate only tip or label, no history. - Binary assets like images, scientific data sets, or game models in the repository are not required. These assets use the Git LFS (Large File Support) extension, which the import tool does not configure. - The imported repository is less than 1GB in size.

Steps to migrate

-   Check out the latest version of your branch from TFVC onto your local disk.
-   Remove binaries and build tools from your repository and set up a package management system like NuGet.
-   Convert version control system-specific directives that you need to retain in Git. For example, convert .tfignore files to .gitignore, and convert .tpattributes files to .gitattributes.
-   Check in the final changes to Team Foundation Version Control and perform the migration to Git. 
-   This can be achieved using in-built Migration Tool VSTS TFVC-TO-GIT. Migration steps are  straightforward and can followed from the Microsoft guide [here](https://docs.microsoft.com/en-us/azure/devops/repos/git/import-from-TFVC?view=azure-devops)

Best Practices / Things to consider before migration

  1. Choose ideal branching strategy – Select the best suited branching model. Details regarding the branching models can be explored here.
  2. Migrating the source control can lead to some code refactoring or restructuring. It is most effective to have one project/solution per Git repository.
  3. Binary Files or executables that slipped into the codebase, like NuGet packages, npm packages, zip files, dlls can be removed and referenced in better ways.
  4. When migrating from TFVC to GIT there are tools that import and migrate the information along with history information, but Microsoft recommends that you don’t import history.
  5. Avoid synchronization issues by locking the TFVC repository during migration.
  6. More information on planning a migration to Git can be read in Microsoft docs here

Suggested configuration changes in TFS to help enable smoother AZDO migration

  1. Upgrade to the latest TFS version. Upgrade TFS to a version that is supported by the TFS Migrator Tool.
  2. Make the collection to be ready to migrate by modifying process templates to suite Azure DevOps process.
  3. On-premise Azure Active Directory Sync. By synchronizing the local Active Directory with the Azure Active Directory, team members can use the current login details.
  4. Generate mappings between your on-premises users and Azure AD. Take backup and restore to the Azure Blob storage.

References

  1. https://simpleprogrammer.com/git-vs-tfvc/
  2. https://www.aligneddev.net/blog/2019/i-like-git-over-tfvc/
  3. https://medium.com/@sunilbanare/azure-devops-tfvc-to-git-migration-14ce3ef18360
  4. https://github.com/git-tfs/git-tfs/blob/master/doc/usecases/migrate_tfs_to_git.md
  5. https://blog.cellenza.com/devops/migrating-from-tfvc-to-git/
  6. https://www.dotnetcurry.com/devops/1540/code-migration-azure-devops
  7. https://github.com/git-tfs/git-tfs/blob/master/doc/usecases/manage_tfs_branches.md