https://docs.microsoft.com/en-us/devops/develop/git/migrate-from-tfvc-to-git
Migrate from TFVC to Git
Azure DevOps provides a simple migration tool to migrate from Team Foundation Version Control to Git.
Before migrating source code from a centralized version control system to Git, understand the differences between the two and prepare for the migration.
Requirements
In order to make migrations simple, there are a number of requirements on the TFVC Import tool:
- Only a single branch is migrated. When planning the migration, choose a new branching strategy for Git. Migrating only the main branch supports a topic-branch based workflow like GitFlow or GitHub Flow.
- A tip migration, importing only the latest version of the source code, is suggested. If TFVC history is simple, there is an option to migrate some history, up to 180 days, so that the team can work only out of Git. For more information, see Plan your migration to Git.
- Binary assets like images, scientific data sets, or game models must be excluded from the repository. These assets should use the Git LFS (Large File Support) extension, which the import tool does not configure.
- The imported repository cannot exceed 1GB in size.
If the repository does not meet these requirements, use the Git-TFS tool to perform the migration.
In general, the process to migrate from TFVC is very easy:
Steps to migrate
- Check out the latest version of the branch from TFVC onto the local disk.
- Remove binaries and build tools from the repository and set up a package management system like NuGet.
- Convert version control system-specific directives. 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.
Steps 1-3 are optional. If there are not binaries in the repository and there is no need to set up a
.gitignore
or a .gitattributes
, then skip straight to
performing the migration.
Check out the latest version
Create a new TFS workspace and map a working folder for the server directory being migrated to Git. This
does not require a full working folder mapping. Only map folders that contain binaries to be removed
from the repository and folders that contain version control system-specific configuration files like
.tfignore
.
Once mappings are set up, get the folder locally:
tf get /version:T /recursive
Remove binaries and build tools
Due to the way Git stores the history of changed files by providing a copy of every file in history to every developer, checking in binary files directly to the repository will cause it to grow quickly and cause performance issues.
For build tools and dependencies like libraries, adopt a packaging solution with versioning support, such as NuGet. Many open source tools and libraries will already be available on the NuGet Gallery, but for proprietary dependencies, create new NuGet packages.
Once dependencies are moved into NuGet, make sure that they will not be included in the Git repository
by adding them to .gitignore
.
Convert version control-specific configuration
Team Foundation Version Control provides a .tfignore
file that will ensure that certain files are
not added to the TFVC repository. This can be used for automatically generated files like build output
so that it is not accidentally checked in.
If the project relies on this behavior, convert the .tfignore
file to a
.gitignore
file.
Cross-platform TFVC clients also provide support for a .tpattributes
file that controls how files
are placed on the local disk or checked in to the repository. If a .tpattributes
file is in use,
convert it to a .gitattributes
file.
Check in to TFVC and perform the migration
Check in any changes that remove binaries, migrate to package management, or convert version control-specific configuration. Once this final change is made in TFVC, the import can be performed.
Follow the Import repositories documentation to actually perform the input.
Advanced migrations
The Git-TFS tool is a two-way bridge between Team Foundation Version Control and Git, and can be used to perform a migration. Git-TFS is appropriate to attempt a migration with full history, more than the 180 days that the Import tool supports, or to attempt a migration that includes multiple branches and merge relationships.
Before attempting a migration with Git-TFS, be aware that there are fundamental differences between the way TFVC and Git store history:
- Git stores history as a snapshot of the repository in time, while TFVC records the discrete
operations that occurred on a file. Change types in TFVC like rename, undelete and rollback cannot
be expressed in Git. Instead of seeing that file
A
was renamed to fileB
, it will only track that fileA
was deleted and fileB
was added in the same commit. - Git does not have a direct analog of a TFVC label. Labels can contain any number of files at any specific version and can reflect files at different versions. Although conceptually similar, Git tags point to a snapshot of the whole repository at a point in time. If the project relies on TFVC labels to know what was delivered, Git tags may not provide this information.
- Merges in TFVC occur at the file level, not at the entire repository. Only a subset of changed files may be merged from one branch to another. Remaining changed files may then be merged in a subsequent changeset. In Git, a merge affects the entire repository, and both sets of individual changes cannot be seen as a merge.
Because of these differences, it is recommended that users do a tip migration and keep their TFVC repository online, but read-only, in order to view history.
To attempt an advanced migration with Git-TFS, see cloning a single branch with history or cloning all branches with merge history.
Update the workflow
Moving from a centralized version control system to Git is more than just migrating code. The team needs training to understand how Git is different from the existing version control system and how these differences affect day-to-day work.
Learn more about migrating from centralized version control to Git.
Recommended content
-
Import repositories from TFVC to Git - Azure Repos
Search your Git repo in Azure DevOps Services or TFS for a specific file or folderImport your repositories from TFVC to Git repositories within the same account.
-
Plan your migration to Git - Azure DevOps
Switching from centralized version control to Git? Git uses a fundamentally different model for storing code. Here's what you need to know.
-
Git and TFVC version control - Azure Repos
Choosing which version control to use in Azure Repos
-
Use TFVC and Git repos in the same project - Azure Repos
Using Version Control for your project in Azure DevOps
No comments:
Post a Comment
Note: only a member of this blog may post a comment.