共用方式為


Use version control

Whether your software project is large or small, we generally recommend that you use version control as early as possible in the lifecycle of your project.

  • When should I use version control?

  • Which version control system should I use: TFVC or Git?

  • Details on the differences between TFVC and Git

When should I use version control?

Every time you create a code project (Keyboard: Ctrl + 0, N), you have the option to add it to version control.

New Project

Should you select the box? The short answer is yes. The more detailed answer depends on your situation.

Small projects

Even if you’re working alone on a small project, you can use version control to improve your personal productivity and recover from difficult problems.

  • I just want to get started coding right away. I’m not sure if I care about sharing right now, but I might in the future.
    You can begin using Git version control before you write your first line of code with virtually no cost or risk. You get many benefits, including being able to revert to a known good state whenever you get in trouble. All this is done on your local dev machine, with no server required. When you’re ready, you can quickly share your code and begin collaborating in TFS or on a third-party Git service. Get started using Git.

  • I’m looking for a simple system that makes it easy for me to collaborate with others right now.
    For not much more additional time, you can create a team project and get started using Team Foundation Version Control (TFVC). You can use either Visual Studio Online or an on-premises Team Foundation Server (TFS). Get started using Team Foundation Version Control (TFVC).

Larger projects

If you work with a team or on complex projects, you should almost certainly work in a shared, version-controlled file system so that you can improve collaboration and transparency. You can also take advantage of integrated automated builds, project planning and tracking, and other Application Lifecycle Management capabilities if you use TFS (either on-premises or in the cloud).

Which version control system should I use?

When you create a new team project you choose the version control system your team will use in that project: Team Foundation Version Control (TFVC) or Git. This is a permanent choice for each team project you create, but you can use both TFVC and Git team projects in the same team project collection.

Connecting to a TFVC team project

Team Foundation Version Control (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 enables two models for your team to make changes:

  • Server workspaces: Before making changes, team members publicly check out files. Most operations require developers to be connected to the server. (In the past teams blocked more than one person from checking out, but this is now less common.) This system facilitates locking work flows. Other systems that work this way include Visual Source Safe, Perforce, and CVS.

  • 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.

Learn more about Team Foundation Version Control (TFVC).

Git distributed version control (distributed)

Git is a distributed version control system. Each developer has a copy of the entire 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. Another system that works this way is Mercurial.

Important

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

Learn more about Git.

Details on the differences between TFVC and Git

Here’s a comparison chart to help you make a choice between TFVC and Git.

Capability

TFVC

Git

Alerts

Team members can receive email alerts when check-ins occur.

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 to TFS. (Anyone can claim any identity as the author or committer.) You can identify when changes were made what was changed using history, compare, and annotate.

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 an additional 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 merging.

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 are 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.

Builds (automated by TFBuild)

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

You can use most TFBuild capabilities to build one team project at a time, and one or more repositories at a time. Gated check-in builds aren’t available yet. Symbols can be published, but they are not indexed yet.

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 cannot 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.

Code reviews in TFS

Yes

Not available yet, but you can comment on and send email about a commit from the web portal.

CodePlex support

Yes

Yes

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. Other types of conflicts can be resolved 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. Avoid checking in large binary files, especially those that you modify often. If possible, use NuGet as an alternative to checking in binary files.

Files on the client dev machine

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

You can browse your files using Windows File Explorer or the command prompt. You cannot yet browse files in Visual Studio.

Files on the server

Each team 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 team project exists on only one server.

Each team 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 cannot be locked.

You can browse your files on the web portal.

You can push commits to multiple remote repositories (for example to both your team project repository and to your web site hosted on Windows Azure.

History

File history is not 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. On the web portal you can annotate files to see who changed a line, and when they changed it.

Manage work on your dev machine

Pending changes and my work pages

Changes, commits, and branches pages.

Migration path

Git-TF

Git-TF

Quality gates

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

You can use CI builds. Gated check-in builds aren’t available yet.

Roll back changes

You can roll back one or more changesets

You can revert a commit

Scale

You can work on small or very large scale projects using local workspaces. Supports 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 team project.

Suspend your work

You can suspend from my work page or shelve your changes.

You can create a branch from (from Visual Studio or the command prompt) or stash (from the command prompt)

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.

Tools

Client tools: Visual Studio, Eclipse (with Team Explorer Everywhere)

Server tool: TFS

Client tools: Visual Studio, Eclipse, and other third-party tools

Server tools: TFS and third-party services

User interface

Visual Studio: Offers all commonly used features and many advanced features.

TFS web portal: Can browse, comment, annotate, and see history of the codebase.

TF Command prompt: Installed with Visual Studio. Used for advanced, administrative, and other less common tasks.

Visual Studio: Offers many commonly used features. Features for some common tasks are not yet available.

TFS web portal: Can browse, comment, annotate, and see history of the codebase.

Third-party command prompt: You can install it from Visual Studio. Used for some common and many less common tasks.

Visual Studio compatibility

You can use all supported previous versions of Visual Studio.

You can use Visual Studio 2013 (Git is included) or Visual Studio 2012 Update 3 (you must also install Visual Studio Tools for Git).

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.