Udostępnij za pośrednictwem


Develop and share your code in TFVC using Visual Studio

TFS 2017 | TFS 2015 | TFS 2013

Visual Studio 2019 | Visual Studio 2017 | Visual Studio 2015 | Visual Studio 2013

Whether your software project is large, small, or brand new, in most cases you'll be better off if you use version control as early as possible. Here, we'll show you how to get started with Team Foundation Version Control (TFVC), a centralized system. If you want to work in a distributed system, you can instead use Git with Azure Repos.

Is your code in another place? Learn how to migrate it here.

Open your project in Visual Studio

  1. Before you start, if you haven't already:

  2. Go to your project's page (https://dev.azure.com/{your organization}/{your team project}) and then open Visual Studio to connect to your project.

    On your project overview page, click Open in Visual Studio

  3. Sign in to Azure DevOps Services from Visual Studio.

Configure your workspace

  1. In Visual Studio, configure your workspace.

    On Team Explorer home page, click Configure Workspace

    I don't see the Configure Workspace link. What do I do next?

  2. Confirm your workspace path, map your workspace, and get the source.

    On Team Explorer home page, click Map and get

  3. Now you can check in source, queue builds, and manage work.

    Visual Studio is now connected to your project

Note

TFVC is not supported when workspaces are placed on network drives or UNC paths.

Create a new app

If you already have an app that you want to add to version control, skip down to Add an existing app.

New solution from team explorer

Now that you've added your app, you can skip down to snapshot your code.

Add an existing app

Move and open the solution

  1. Close the solution.

  2. Open the workspace folder that you created when you configured your workspace.

    Open the workspace folder from source control explorer

  3. Move the code you want to upload to the workspace folder.

    Move your source code to your workspace folder

  4. Open your solution in Visual Studio.

    Open your solution in Visual Studio

Add the solution to Azure Repos

  1. Open the solution explorer (Keyboard: Ctrl + Alt + L).

  2. Add your solution to version control.

    Add the solution to Azure Repos

  3. Check in the solution.

    Check in your solution

  4. Add a comment and check in.

    Add a comment and check in pending changes

  5. Open the source control explorer.

    Open the source control explorer

    Your solution is now in TFS.

    Your solution in the source control explorer

Your whole team can work on the code now. All your changes are tracked in version control.

Snapshot (check in) your code

  1. When you edit code in Visual Studio, the changed file is automatically checked out. For example, Site.css is checked out after the border color has been changed to #ddd.

    Checked out file in the team explorer

  2. Compare the modified file with the latest version in source control.

    Compare in the solution explorer's context menu

    You can see the difference between the two versions.

    Compare window

  3. Check in the changes.

    Check in from the context menu in the solution explorer

    You can also check in from the code window, or the team explorer.

  4. If you're working on a task or fixing a bug that's tracked as a work item, add that work item to your pending changes. Source control will resolve the bug or close the task, and it'll link the changeset to the work item.

    Related work items in pending changes

  5. Add a comment and check in.

    Source control explorer, source file context menu, check in

  6. Open the source control explorer.

    Source control explorer in the team explorer home page

  7. View the history of the file you changed.

    Source control explorer, source file context menu, view history

    All the changesets that include this file are listed.

    History window

Troubleshooting

My code is somewhere else. Can I migrate it to my TFVC project on Azure DevOps Services?

Yes. See Migrate from Team Foundation Server into Azure DevOps Services.

You might already have a workspace on your computer. To see your workspace, open Source Control Explorer. Or change your workspace. Find out how to manage files under source control or manage workspaces.

In Team Explorer, click Source Control Explorer or Manage Workspaces

Next steps