How to rollback in Visual Studio TFS?

2019-02-01 04:05发布

I'm working on one sub-module of a large project for which is use VSTS 2008.

I have a need to rollback the module to an earlier version (about 4 check-ins previous). I tried to do this in the Visual Studio UI, and finally realized there is no option to rollback.

After some research, I determined there is a power tools download that purports to support rollback via a command-line tool. However, there appears to be virtually no documentation for it.

Can anyone describe step by step how to rollback to a previous version in VS2008? (Using Power Tools or otherwise).

Bonus question--anyone know if we might get more robust rollback support in VS2010?

7条回答
Lonely孤独者°
2楼-- · 2019-02-01 04:36

Bonus question--anyone know if we might get more robust rollback support in VS2010?

Yes. Unlike the Power Tools, which is coded directly against the existing 2008 client API, TFS 2010 has a new API for executing rollbacks directly on the server. This makes them far faster and more reliable, while adding functionality that wasn't possible at all in 2008 such as reverting merge history.

查看更多
走好不送
3楼-- · 2019-02-01 04:37

The August 2011 TFS Power Tools added full rollback support right into the Visual Studio 2010 UI.

Download link: http://visualstudiogallery.msdn.microsoft.com/c255a1e4-04ba-4f68-8f4e-cd473d6b971f

This function is also included with TFS 2012.

查看更多
4楼-- · 2019-02-01 04:42

There IS a way but I don't find it pretty.. Open Visual Studio command prompt and ..

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>tf rollback -?
TF - Team Foundation Version Control Tool, Version 10.0.30319.1
Copyright (c) Microsoft Corporation.  All rights reserved.

Rolls back the changes in a single or a range of changesets:
tf rollback /changeset:changesetfrom~changesetto [itemspec] [/recursive]
            [/lock:none|checkin|checkout] [/version:versionspec]
            [/keepmergehistory] [/noprompt] [/login:username,[password]]

tf rollback /toversion:versionspec itemspec [/recursive]
            [/lock:none|checkin|checkout] [/version:versionspec]
            [/keepmergehistory] [/noprompt] [/login:username,[password]]

Versionspec:
    Date/Time         D"any .Net Framework-supported format"
                      or any of the date formats of the local machine
    Changeset number  Cnnnnnn
    Label             Llabelname
    Latest version    T
    Workspace         Wworkspacename;workspaceowner
查看更多
Fickle 薄情
5楼-- · 2019-02-01 04:44

This has luckily been made much easier in TFS 2012. Now there is a Rollback option from the GUI.

MSDN has more information on how to do it, and what options are available. Here is the text from MSDN on how to rollback to a specific version:

To roll back to a specific version:

  1. In Source Control Explorer, select an item, open its shortcut menu, and choose Rollback.
  2. In the Rollback dialog box, select Rollback to a specific version.

You can of course also rollback entire changesets or a collection of changesets. And you can also easily rollback to a specific point in time if you wish.

查看更多
我只想做你的唯一
6楼-- · 2019-02-01 04:48

From the MSDN article How to: Roll Back a Changeset (VS2008 although other versions are available)

To revert to an earlier version of a file

  1. In Source Control Explorer, right-click the file that you want to roll back, and then click Get specific version. The Get dialog box appears.
  2. Under Type, click Changeset.
  3. Under Changeset, click the ellipses (…).
  4. In the Find Changesets dialog box, either use the default values or specify criteria for your search, and then click Find.
  5. Under Results, click the changeset that contains the version to which you want to revert the file, and then click OK.
  6. In the Get dialog box, select the Overwrite writable files that are not checked out check box, and then click Get. The earlier version of the file is copied to your local working folder.
  7. In Source Control Explorer, right-click the file, and then click Check Out for Edit.
  8. In the Check Out dialog box, click Check Out.
  9. In Source Control Explorer, right-click the file again, and then click Check In Pending Changes.
  10. In the Check In - Source Files dialog box, click the file, and then click Check in. The Resolve Conflicts dialog box appears, and a message explains that no files have been checked in because the two versions have changes that conflict.
  11. In the message box, click OK. The Pending Changes – Conflicts window appears.
  12. (Optional) In the toolbar of the Pending Changes window, click Compare Local to Server. The server and local copies appear side by side so that you can review your decision before you roll back the changes
  13. In the Pending Changes window, click Keep Local Version.
  14. In Source Control Explorer, right-click the file, and then click Check In Pending Changes.
  15. In the Check In - Source Files dialog box, click Check in.
查看更多
冷血范
7楼-- · 2019-02-01 04:51

In Visual Studio 2013 this became an easier task. To Rollback, do the following:

  1. In Source Control Explorer, select the solution/project
  2. Right-click, then select "View History"
  3. In the history view, select the changeset you want to roll back
  4. Right-click, then select View changeset details. This opens up the Team Explorer.
  5. In the Team Explorer, click "Rollback":
    Team Explorer
  6. To make the rollback permanent, you need to check in now. Or you can make changes to the rolled back version and then check in.
查看更多
登录 后发表回答