Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
MSDN Library

Undo command

Discards one or more pending changes to files or folders.

Requirements: See Pernission reference for Team Foundation Server.

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



/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.


Specifies the scope of the items. You can specify more than one itemspec argument. For syntax, see Use Team Foundation version control commands.


Specifies the user account to use to run the command. See Use Team Foundation version control commands.


Suppresses the display of windows and dialog boxes and redirects output data to the command prompt. See Use Team Foundation version control commands.


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

/workspace workspacename[;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 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.

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.

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

Removes all pending changes to program.cs.

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

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

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.

  • 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).

© 2015 Microsoft