Undo Command

Discards one or more pending changes to files or folders.

Requirements: See Team Foundation Server Permissions.

tf undo [/workspace:workspacename[;workspaceowner]]
[/recursive] itemspec [/noprompt] [/login:username,[password]]
[/collection:TeamProjectCollectionUrl]

Parameters

Parameter

Description

/collection : TeamProjectCollectionUrl

Specifies the URL of the team project collection that contains the items. For example: http://myserver:8080/tfs/DefaultCollection.

If you do not use the /workspace option, by default the team project collection is presumed to be the one that contains the workspace that maps the current directory.

itemspec

Specifies the scope of the items. You can specify more than one itemspec argument. For syntax, see Team Foundation Version Control Command Reference.

/login

Specifies the user account to use to run the command. See Team Foundation Version Control Command Reference.

/noprompt

Suppresses the display of windows and dialog boxes and redirects output data to the command prompt. See Team Foundation Version Control Command Reference.

/recursive

Recursively undoes changes to items in the specified directory and any subdirectories.

/workspaceworkspacename[;workspaceowner]

Specifies the name of the workspace in which you want to undo pending changes. If not specified, the workspace is the one that maps the current directory.

You can specify workspaceowner to undo a pending change in a workspace that belongs to a specific user. If not specified, the workspace is presumed to be the current user, or if specified, the /login:username. You must have the UndoOther permission set to Allow to undo changes in another user’s workspace.

Note

If you use the undo command to undo a pending change in a remote workspace that is still in use, then before continuing work in that workspace, a user must log on to the machine that hosts the workspace and then get (and in some cases get /all) the items affected by the undo.

Remarks

For each item on which there is a pending edit change, the undo command determines if the file has been modified on disk. If the file has been modified and the /noprompt option has not been specified, the system prompts you to confirm that you want to proceed. Choose the N key to leave the change in place, the Y key to proceed with only the current change, or the A key to proceed with this and any other modified files that are subsequently detected.

The undo command removes any locks on the items.

Examples

Remove pending changes to a file

c:\code\SiteApp\Main\SolutionA\Project1>tf undo program.cs

Removes all pending changes to program.cs.

Recursively remove pending changes to all items in a folder

c:\code\SiteApp\Main>tf undo * /recursive

Removes all pending changes in the c:\code\SiteApp\Main folder and all its subfolders.

Remove pending changes to a file in a remote workspace

c:\>tf undo /collection:http://fabrikam-3:8080/tfs/DefaultCollection
/workspace:FABRIKAM-1;JuliaI $/SiteApp/Main/SolutionA/Project1/program.cs

Removes all pending changes to program.cs in the specified collection and workspace.

Work in Visual Studio

Tips

  • Tip To view a list of pending changes in the current or in a remote workspace, use the Status Command.

  • Tip You can use the /workspace option (and as needed, the /collection option) to undo changes on a remote dev machine. This capability is especially useful in cases when, for example, a file has been checked out and possibly locked on a dev machine that you cannot access. See the above explanation of the /workspace for information about how this works.

  • Tip If you need to clean your workspace (for example, because your work is interrupted by a more urgent task) and want to preserve the pending changes instead of undoing them, you can suspend them. See Shelve Command. You can also preserve the position of your open windows, breakpoints, and other important cues. See Suspend Your Work and Manage Your Shelvesets.

  • Tip You can also discard changes that have already been checked in. See Undelete Command and Rollback Command (Team Foundation Version Control).