Freigeben über


Rename or move files and folders in TFVC

TFS 2018

Visual Studio 2019 | Visual Studio 2022

For files in Team Foundation Version Control (TFVC), you can use Visual Studio Source Control Explorer to move or rename one file or folder at a time.

You can also use the tf command-line utility to move or rename files or folders in TFVC. For more information, see Rename command (Team Foundation Version Control).

Important

  • Don't use Source Control Explorer to move folders or files that a Visual Studio project or solution references. Move these files with Solution Explorer instead, and use a new changeset to check in the move.

  • If you're not using TFVC for version control, use Solution Explorer to move and rename files in Visual Studio solutions or projects.

Prerequisites

You must be one of the Contributors for your project. For more information, see Default TFVC permissions.

Move an item

  1. In Source Control Explorer, right-click the item that you want to move and choose Move.

  2. In the Move dialog box, manually enter the destination for the item in the To box, or choose Browse to use the Browse for Folder dialog box.

  3. Choose OK.

Rename an item

  1. In Source Control Explorer, right-click the file you want to rename and choose Rename.

  2. Enter the new name for the item.

  3. Choose OK.

Fix the outcome after you rename an item in your operating system

Avoid using your operating system, such as Windows File Explorer or the Windows command prompt rename command, to rename items that are managed by TFVC. If you do use your operating system to rename an item in a local workspace, Visual Studio detects the change as two changes: an add and a delete. You can join the two actions into a rename action.

Note

This issue doesn't apply to Git version control.

  1. In Visual Studio Team Explorer, choose Pending Changes.

  2. In the Excluded Changes section of the Pending Changes page, select Detected.

  3. In the Promote Candidate Changes dialog box, select the delete and add actions, right-click, and choose Promote as Rename.

  4. A single rename change now appears in the Included Changes section.

Tip

  • When you begin a new task, it's a good practice to download the latest files from the server before you make changes to files in your workspace.
  • Avoid renaming an item that has been branched but not yet checked in. If you try to do so, a conflict occurs.

Next steps

You can review and manage your work, suspend your work, and ultimately contribute your work to the team's codebase.