Поделиться через


Rename Command (Team Foundation Source Control)

The rename command changes the name or the path of a file or folder. You can use the rename command or the alias move, to move a file or folder to a new location.

Note

The results of this command are not reflected in the Team Foundation source control server until you perform a check-in operation. For more information, see How to: Check In Pending Changes.

tf rename [/lock:(none|checkout|checkin)] olditem newitem

Parameters

Argument Description

olditem

The original name and path of the file or folder that is to be renamed. You can specify a local workspace path such as C:\myfiles\314.cs or a Team Foundation source control server path such as $/myfiles/314.cs.

newitem

The new name of the file or folder. You can use this to specify a different local or a Team Foundation source control server path location.

Option Description

/lock

Include this option to prevent other users from checking in or checking out the specified items. If this option is not specified, the lock status of the item is not changed. For more information, see Understanding Lock Types.

Lock Options:

  • None   No lock is applied. If a lock exists on the specified file, this option removes it.

  • Checkin   Other users can check out the specified items but they cannot check in revisions to locked files until you release the lock by performing a check-in. If any other users have locked any one of the specified items, the lock operation fails.

  • Checkout   Prevents other users from checking in or checking out any one of the specified items until you release the lock by performing a check-in. If any other users have locked any one of the specified items, the lock operation fails.

Remarks

You can use the rename command of the tf command-line utility to move or rename a source-controlled item in your workspace. Use the rename command to move multiple files by specifying wildcard characters. The ability to rename multiple source-controlled files or folders, is only available from the command-line.

Use Rename to do the following:

  • Rename the olditem ** to the newitem, such as tf rename 314.cs 315.cs.

  • Move the olditem to a new location in the Team Foundation source control server by providing a newitem whose path differs from that of the olditem, such as  tf rename 314.cs ..\newdir\314.cs.

If you provide a newitem that specifies a non-existent folder, the rename command creates the destination folder. If newitem is a folder, olditem becomes a child of newitem.

You cannot rename an item if:

  • You have already deleted it before it was checked-in in the same workspace.

  • The new name already exists in the Team Foundation source control server and is not a folder.

  • You have already added, branched, or renamed the item pending check-in.

  • The item is mapped in the workspace but not available on the local disk.

  • The item is cloaked.

You can rename an item for which another file of the same name has been added pending check-in but you cannot rename an item that has been branched but not yet checked in. When you rename a file that has pending edits, the edits are preserved. If you rename a file for which a pending rename has been recorded, the initial rename change is replaced by the second rename change.

An item that is explicitly mapped cannot be renamed without first changing the mapping. For example, if there is a working folder mapping of $/ProjectX/MyApp to c:\MyApp, you cannot rename MyApp. You can rename items under MyApp but not MyApp itself.

Examples

The following example changes the name of 314.c to 1254.c.

c:\projects>tf rename  314.c  1254.c

The following example renames 314.c to 1254.c and moves it to the newdir folder.

c:\projects>tf rename 314.c ..\newdir\1254.c

The following example changes the name of Form1.vb to MainPage.vb and reserves that name such as $/VBApplications/Project2/MainPage.vb) so that other users cannot create a file named MainPage.vb in the same location before the changes are checked in, or the lock is released.

c:\projects>tf rename Form1.vb MainPage.vb /lock:checkin

Security

To use the rename command, you have the Check out permission set to Allow. For more information, see Team Foundation Server Permissions.

See Also

Tasks

How to: Move, Rename, and Delete Source-Controlled Files and Folders

Reference

Command-Line Syntax
Add Command
Delete Command (Team Foundation Source Control)
Get Command

Concepts

Understanding Lock Types
Pending Changes

Other Resources

Tf Command-Line Utility Commands