Condividi tramite


Rename or move files and folders

Important

Avoid renaming items under version control using your operating system (for example, using File Explorer, or the rename command in the Windows command prompt). Instead, you should follow the procedures below to rename your files and folders. Otherwise, you might get unintended results.

Required permissions

You must be one of the Contributors for your team project. See TFS default groups, permissions, and roles [redirected].

What do you want to do?

  • Move an item

  • Rename an item

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

  • Work from the command prompt

  • Get tips

Move an item

You can use Source Control Explorer one file or folder at a time. You should not use Source Control Explorer to move folders or files that are referenced by a code project.

  1. In Source Control Explorer, select the item that you want to move, open its shortcut menu, and choose Move.

  2. In the Move dialog box, either manually type 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 in Visual Studio

You can use either Source Control Explorer or Solution Explorer to rename a file. If you use Source Control Explorer, you can also change the file extension.

To rename an item

  1. In either Solution Explorer or Source Control Explorer, select the file that you want to edit, open its shortcut menu, and choose Rename.

  2. Type the desired name for the item.

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

You should avoid renaming items under version control using your operating system (for example, using Windows File Explorer, or the rename command in the Windows command prompt). When you have used your operating system to rename an item in 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.

To fix the results of an operating system rename

  1. In Visual Studio, in Team Explorer, choose Home iconHome, and then choose Pending Changes.

  2. In the Excluded Changes section, choose the Detected changes link.

  3. In the Promote Candidate Changes dialog box, select the delete and add actions, open their shortcut menu, and choose Promote as Rename.

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

Work from the command prompt

Tips