Редактиране

Споделяне чрез


Choosing the right version control for your project

Azure DevOps Services | Azure DevOps Server 2022 - Azure DevOps Server 2019

Visual Studio 2019 | Visual Studio 2022

Whether your software project is large or small, using version control as soon as possible is a good idea. Azure Repos supports two types of version control: Git and Team Foundation Version Control (TFVC).

Which version control system should I use?

Git is the default version control provider for new projects. You should use Git for version control in your projects and begin to move your existing TFVC projects to Git. TFVC is considered feature complete. Azure DevOps will maintain compatibility with TFVC, but Git will receive all future investment.

You can use TFVC repos with Git in the same project, so it's easy to add TFVC later if you need centralized version control. To set up a new repo type for an existing project use these instructions.

Git (distributed)

Git is a distributed version control system. Each developer has a copy of the source repository on their dev machine. Developers can commit each set of changes on their dev machine and perform version control operations such as history and compare without a network connection. Branches are lightweight. When you need to switch contexts, you can create a private local branch. You can quickly switch from one branch to another to pivot among different variations of your codebase. Later, you can merge, publish, or dispose of the branch.

Note

Git in Visual Studio, Azure DevOps Services, and Azure DevOps Server is standard Git. You can use Visual Studio with third-party Git services, and you can also use third-party Git clients with Azure DevOps Server.

For more information, see Git and Azure Repos.

TFVC (centralized)

Team Foundation Version Control (TFVC) is a centralized version control system. Typically, team members have only one version of each file on their dev machines. Historical data is maintained only on the server. Branches are path-based and created on the server.

TFVC has two workflow models:

  • Server workspaces - Before making changes, team members publicly check out files. Most operations require developers to be connected to the server. This system facilitates locking workflows. Other systems that work this way include Visual Source Safe, Perforce, and CVS. With server workspaces, you can scale up to very large codebases with millions of files per branch and large binary files.

  • Local workspaces - Each team member takes a copy of the latest version of the codebase with them and works offline as needed. Developers check in their changes and resolve conflicts as necessary. Another system that works this way is Subversion.

For more information, see What is Team Foundation Version Control?

Moving from TFVC to Git

If you have existing TFVC repos, you can migrate them to Git repos using the git-tfs tool. The tool allows you to migrate a TFVC repo to a Git repo in just a couple of commands.

Git and TFVC capabilities

The following table provides a summary of how TFVC and Git support the main capabilities of version control.

Capability

TFVC

Git


Changes

Team members can concurrently change files on their dev machines. You upload (check-in) changesets to the server when you create them. You can upload your changes at any time. However, you might be interrupted by conflicts.

You can change the comment of a changeset after you check it in. You can link changesets to work items and associate them with completed builds.

Team members can concurrently change files on their dev machines. You create commits on your dev machine independently of contributing them to the team. When you're ready, you must pull the latest commits before you upload (push) yours to the server. When you pull, you might be interrupted by conflicts.

You can amend the latest local commit. You can't change older commits. You can link commits to work items and associate them with completed builds.

You can modify and combine local commits from the command prompt.

Branching

Path-based branches are used mostly as long-standing constructs to isolate risk of change among feature teams and releases. Team members typically set up a different workspace for each branch they work on.

Changes in each branch are independent from each other, so you don't have to check them in before switching from one branch to another. Merging between sibling branches requires a baseless merge.

You can get visualizations of your branch structures and where your changesets have been merged.

See Use branches to isolate risk in Team Foundation Version Control.

Branching is lightweight and path independent. Many developers create a branch for each new feature they're coding, sometimes on a daily basis. You can quickly switch from one branch to another to pivot among different variations of your codebase. You can create branches that exist only on your dev machine and share them if and when you're ready.
You must commit, branch, stash, or undo changes before switching branches. Merging is simple and independent of the commit that the branch is based on. You can compare branches to see which commits exist on which branches.

See Use Git branches to switch contexts, suspend work, and isolate risk.

Conflict resolution

You might have to resolve conflicts when you get, check in, merge, or unshelve. You can resolve all types of conflicts in Visual Studio.

You might have to resolve conflicts when you pull or merge. You can resolve content conflicts in Visual Studio or from the command prompt.

File storage

You can check in large binary files. You might also want to use NuGet in combination or as an alternative.

You can check in small binary files as you would regular files. When working with large binary files, use Git-LFS to store your large binary files in Azure Repos.

History

File history isn't replicated on the client dev machine and so can be viewed only when you're connected to the server. You can view history in Visual Studio and on the web portal. You can annotate files to see who changed a line, and when they changed it.

File history is replicated on the client dev machine and can be viewed even when not connected to the server. You can view history in Visual Studio and on the web portal. You can annotate files to see who changed a line, and when they changed it.

Tag your files

You can apply labels to a version of one or more files from either Visual Studio or the command prompt. Each file can have label applied to a different version.

You can apply tags from the command prompt to individual commits. View tags in the Visual Studio history window.

Roll back changes

You can revert a commit.

Scale

You can work on small or very large scale projects using local workspaces. Support massive scale (millions of files per branch and large binary files) projects using server workspaces.

You can quickly begin small projects. You can scale up to very large projects, but you have to plan ahead to modularize your codebase. You can create multiple repositories in a project.

Server

The following table summarizes the features available with the supported servers for each of the version control systems.

Capability

TFVC

Git


Server

Azure DevOps Services, Azure DevOps Server

Azure DevOps Services, Azure DevOps Server, and Git third-party services

Alerts

Team members can receive email alerts when commits are pushed to the server.

Auditability

Because your team checks in all their work into a centralized system, you can identify which user checked in a changeset and use compare to see what they changed. Looking at a file, you can annotate it to identify who changed a block of code, and when they did it.

You can identify which user pushed a commit. (Anyone can claim any identity as the author or person who made the commit.) You can identify when changes were made and what was changed using history, compare, and annotate.

Builds (automated by TFBuild)

You can use all TFBuild capabilities to build any combination of content you want within the project collection.

You can use most TFBuild capabilities to build one project at a time, and one or more repositories at a time.

Code reviews

See Day in the life of a devops developer: Suspend work, fix a bug, and conduct a code review. For more lightweight discussions, you can also comment on and send email about a changeset from the web portal.

See Review pull requests. For more lightweight discussions, you can also comment on and send email about a commit from the web portal.

Files

Each project contains all files under a single root path (for example: $/FabrikamTFVC). You can apply permissions at the file level. You can lock files.

You can browse your files on the web portal and using Source Control Explorer in Visual Studio.

Your project exists on only one server.

Each project can contain one or more Git repositories, and each Git repository can contain one or more branches. The most granular permissions you can apply are to a repository or a branch. Files can't be locked.

You can browse your files on the web portal.

You can push commits to multiple remote repositories, for example to both your project repository and to your website hosted on Azure.

Quality gates

You can use continuous integration (CI) builds, gated check-in builds, and check-in policies.

You can use CI builds and gated check-in builds through branch policies.

Client

The following table summarizes the client supported features available depending on the version control system you select.

Capability

TFVC

Git


Client software

Visual Studio

Visual Studio, Visual Studio Code, Eclipse, and other third-party tools

Files

You can browse your files using Source Control Explorer in Visual Studio, or by using Windows File Explorer or the command prompt.

You can browse your files by using Windows File Explorer or the command prompt.

Manage work on your dev machine

Pending Changes and My Work pages in Visual Studio Team Explorer.

Changes, commits, and branches pages.

Suspend your work

You can suspend work from the My Work page or Shelve your changes on the Pending Changes page. For more information, see Suspend your work and manage your shelvesets.

You can create a branch from Visual Studio or the command prompt, or stash from the command prompt.

Visual Studio compatibility

You can use all supported versions of Visual Studio.

You can use all supported versions of Visual Studio.

Web portal

You can browse your codebase (including branches), view history, annotate and comment on changesets and shelvesets, and perform other tasks such as ad hoc downloading of selected parts of your codebase as a .zip file.

You can browse your codebase, view history, compare branches, annotate and comment on commits, and perform other tasks such as ad hoc downloading of selected parts of your codebase as a .zip file.

Migration

To learn how to migrate from TFVC to Git, see Migrate from TFVC to Git.