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.
In Source Control Explorer, select the item that you want to move, open its shortcut menu, and choose Move.
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.
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
In either Solution Explorer or Source Control Explorer, select the file that you want to edit, open its shortcut menu, and choose Rename.
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
In Visual Studio, in Team Explorer, choose Home, and then choose Pending Changes.
In the Excluded Changes section, choose the Detected changes link.
In the Promote Candidate Changes dialog box, select the delete and add actions, open their shortcut menu, and choose Promote as Rename.
A single rename change now appears in the Included Changes section.
Work from the command prompt
- Rename Command: Rename or move a file.
Tips
If you are beginning 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 will occur.
You can review and manage your work, suspend your work, and ultimately contribute your work to the team’s codebase.