Compartir vía


Set up Team Foundation Version Control on your dev machine

TFS 2018

Visual Studio 2019 | Visual Studio 2022

To set up Team Foundation Version Control (TFVC) on your dev machine, you create a workspace and then add your code.

Prerequisites

Create a workspace and get the code

  1. Press Ctrl+0, C to open the Connect page of the Visual Studio Team Explorer window.

  2. Right-click a project, and then select Connect.

    Screenshot that shows connecting to a project.

    If the project you want isn't listed, select Manage Connections, select Connect to a Project, and then select the project you want. For more information, see connect to a project.

  3. Select Configure your workspace to map the project to a folder on your dev machine.

    Screenshot that shows mapping the project to a folder on your dev machine.

  4. Select Map & Get to map the workspace and get your code.

    Screenshot that shows mapping the workspace to get code.

Work in a Main folder

To prepare for when your team grows large enough to need branches to manage your work, put all your code in a parent folder called Main, for example $/MyTeamProject/Main.

  1. Press Ctrl+0, H to open the Home page of Team Explorer.

  2. Select Source Control Explorer.

  3. In the Source Control Explorer window, select your project in the left pane.

  4. On the Visual Studio menu bar, choose File > Source Control> New Folder.

  5. In Source Control Explorer, rename the folder to Main.

    Screenshot that shows renaming the new folder in Source Control Explorer.

  6. Right-click the Main folder and choose Check in Pending Changes.

  7. On the Pending Changes page, select Check In.

    Screenshot that shows checking in the new folder.

    Your changeset is checked in.

    Screenshot that shows check-in success.

When your team decides to branch the codebase, you can convert the Main folder to a branch. For more information, see Branch folders and files.

Add your code to version control

If you've got an idea for a new app, you can use TFVC version control from the start. Or, you can put an app in progress under TFVC source control.

  1. When you create a new code project that you want to put under TFVC solution control, put it in your mapped workspace folder like c:\Users\<YourName>\Source\Workspaces\YourTeamProject\Main\.

    Or, if you already have an app that you want to put under TFVC source control, move the solution into your workspace folder with Windows File Explorer.

  2. In Visual Studio, press Ctrl+Shift+O and open your solution, and open Solution Explorer by pressing Ctrl+Alt+L.

  3. In Solution Explorer, right-click your solution and select Add Solution to Source Control.

    Screenshot of adding your solution to source control.

  4. In the Add Solution to Source Control dialog box, review the details, and then select OK.

  5. When you're ready, press Ctrl+0, P to check in your changes.

Next steps