visual-studio 如何在 Visual Studio TFS 中回滚?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2276780/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 11:33:12  来源:igfitidea点击:

How to rollback in Visual Studio TFS?

visual-studiotfstfs-power-tools

提问by alchemical

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

我正在处理一个使用 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.

我需要将模块回滚到早期版本(之前大约有 4 次签入)。我尝试在 Visual Studio UI 中执行此操作,最后意识到没有回滚选项。

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

任何人都可以逐步描述如何在 VS2008 中回滚到以前的版本?(使用电动工具或其他方式)。

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

额外的问题——有谁知道我们是否会在 VS2010 中获得更强大的回滚支持?

采纳答案by Brett Widmeier

Right-click on the folder in Source Control Explorer. Choose Get Specific Version. Choose the version that you want to get (by changeset, date, label, etc).

右键单击源代码管理资源管理器中的文件夹。选择获取特定版本。选择您想要获取的版本(按变更集、日期、标签等)。

EDIT: At this point your local version will be the version that you want. Check out the changed files and then check them back in. This will bring up the merge wizard and it will probably be complaining about how the server has a newer version than you do. Go through the wizard and merge the files the way you want them (one of the options is to discard the server changes, which is what it sounds like you want). At the end of this process, it may tell you that no files were checked in due to the merge process (or something of that nature), just hit OK and then check in again. This should accomplish what you need.

编辑:此时您的本地版本将是您想要的版本。检出更改过的文件,然后将它们重新检入。这将调出合并向导,并且它可能会抱怨服务器的版本比您更新的如何。通过向导并按照您希望的方式合并文件(其中一个选项是放弃服务器更改,这听起来像是您想要的)。在此过程结束时,它可能会告诉您由于合并过程(或类似性质)没有签入任何文件,只需点击“确定”,然后再次签入。这应该可以完成您的需求。

回答by René

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

幸运的是,这在 TFS 2012 中变得更加容易。现在 GUI 中有一个回滚选项。

MSDNhas 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:

MSDN提供了有关如何执行此操作以及可用选项的更多信息。以下是 MSDN 上有关如何回滚到特定版本的文本:

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.

要回滚到特定版本:

  1. 在源代码管理资源管理器中,选择一个项目,打开其快捷菜单,然后选择回滚。
  2. 在回滚对话框中,选择回滚到特定版本。

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.

您当然也可以回滚整个变更集或变更集的集合。如果您愿意,您还可以轻松回滚到特定时间点。

回答by Andrei R?nea

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

IS的方式,但我不觉得它漂亮..打开Visual Studio命令提示符,..

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

回答by Warren Rumak

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

2011年8月TFS电动工具添加了完整的回滚支持右到Visual Studio 2010的UI。

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

下载链接:http: //visualstudiogallery.msdn.microsoft.com/c255a1e4-04ba-4f68-8f4e-cd473d6b971f

This function is also included with TFS 2012.

此功能也包含在 TFS 2012 中。

回答by Richard Berg

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

额外的问题——有谁知道我们是否会在 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.

是的。与直接针对现有 2008 客户端 API 进行编码的 Power Tools 不同,TFS 2010 具有用于直接在服务器上执行回滚的新 API。这使得它们更快、更可靠,同时添加了 2008 年根本不可能实现的功能,例如恢复合并历史记录。

回答by John MacIntyre

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

来自 MSDN 文章How to: Roll Back a Changeset(VS2008 尽管其他版本可用)

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.

恢复到文件的早期版本

  1. 在源代码管理资源管理器中,右键单击要回滚的文件,然后单击获取特定版本。出现获取对话框。
  2. 在类型下,单击变更集。
  3. 在变更集下,单击省略号 (...)。
  4. 在“查找变更集”对话框中,使用默认值或指定搜索条件,然后单击“查找”。
  5. 在结果下,单击包含要将文件还原到的版本的变更集,然后单击确定。
  6. 在“获取”对话框中,选中“覆盖未签出的可写文件”复选框,然后单击“获取”。该文件的早期版本将复制到您的本地工作文件夹中。
  7. 在源代码管理资源管理器中,右键单击该文件,然后单击签出进行编辑。
  8. 在“签出”对话框中,单击“签出”。
  9. 在源代码管理资源管理器中,再次右键单击该文件,然后单击“签入挂起的更改”。
  10. 在“签入 - 源文件”对话框中,单击该文件,然后单击“签入”。将出现“解决冲突”对话框,并显示一条消息,说明尚未签入任何文件,因为两个版本的更改存在冲突。
  11. 在消息框中,单击“确定”。将出现待定更改 - 冲突窗口。
  12. (可选)在 Pending Changes 窗口的工具栏中,单击 Compare Local to Server。服务器和本地副本并排显示,以便您可以在回滚更改之前查看您的决定
  13. 在待定更改窗口中,单击保留本地版本。
  14. 在源代码管理资源管理器中,右键单击该文件,然后单击签入挂起的更改。
  15. 在“签入 - 源文件”对话框中,单击“签入”。

回答by Matt

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

Visual Studio 2013 中,这变得更容易了。要回滚,请执行以下操作:

  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 innow. Or you can make changes to the rolled back version and then check in.
  1. Source Control Explorer 中,选择解决方案/项目
  2. 右键单击,然后选择“查看历史记录”
  3. 在历史视图中,选择要回滚的变更集
  4. 右键单击,然后选择查看变更集详细信息。这将打开团队资源管理器。
  5. 在团队资源管理器中,单击“回滚”
    团队资源管理器
  6. 要使回滚永久化,您需要立即签入。或者您可以对回滚的版本进行更改,然后签入。