如何回滚TFS签到?

时间:2021-11-23 22:36:16

I'd like to rollback a change I made recently in TFS. In Subversion, this was pretty straightforward. However, it seems to be an incredible headache in TFS:

我想回滚一下我最近在TFS中做出的改变。在Subversion中,这非常简单。然而,它似乎是TFS令人难以置信的头痛:

Option 1: Get Prior Version

  1. Manually get prior version of each file
  2. 手动获取每个文件的先前版本

  3. Check out for edit
  4. 退房编辑

  5. Fail - the checkout (in VS2008) forces me to get the latest version
  6. 失败 - 结账(在VS2008中)迫使我获得最新版本

Option 2: Get TFS Power Tools

  1. Download Team Foundation Power Tools
  2. 下载Team Foundation Power Tools

  3. Issue rollback command from cmd line
  4. 从cmd行发出回滚命令

  5. Fail - it won't work if there are any other pending changes
  6. 失败 - 如果有任何其他待定更改,它将无法工作

Option 3: Manually Undo Changes

  1. manually undo my changes, then commit a new changeset
  2. 手动撤消我的更改,然后提交新的更改集

Question

How do I rollback to a previous changeset in TFS?

如何回滚到TFS中的先前变更集?

17 个解决方案

#1


63  

  1. Download and install Team Foundation Power Tools.
  2. 下载并安装Team Foundation Power Tools。

  3. Open up the Visual Studio command prompt
  4. 打开Visual Studio命令提示符

  5. Navigate to the directory on the file system that TFS is mapped to. If you don't do this you'll get an "Unable to determine the workspace" error when you try to roll back
  6. 导航到TFS映射到的文件系统上的目录。如果您不这样做,当您尝试回滚时,您将收到“无法确定工作区”错误

  7. Make sure everything else is checked in or shelved
  8. 确保其他所有内容都已签入或搁置

  9. run tfpt rollback to bring up the interface.
  10. 运行tfpt rollback以调出界面。

  11. Choose the changesets you want to rollback
  12. 选择要回滚的更改集

  13. Check in the new versions of the files you rolled back
  14. 签入您回滚的文件的新版本

The big disadvantage of the tool is that it will want to refresh everything in your workspace before you can merge. I got around this issue by creating a new workspace just for the rollback which mapped directly to the place in the source tree where the affected files were.

该工具的最大缺点是它需要在合并之前刷新工作区中的所有内容。我通过为回滚创建一个新工作区来解决这个问题,该工作区直接映射到受影响文件所在的源树中的位置。

If you need help to figure out which changesets to roll back, I find the code review tool in the free Team Foundation Side Kicks add-in very helpful.

如果您需要帮助来确定要回滚的更改集,我会发现免费的Team Foundation Side Kicks插件中的代码审查工具非常有用。

#2


24  

Your solution #1 will work: 1. manually get prior version of each file

您的解决方案#1将起作用:1。手动获取每个文件的先前版本

  1. check out for edit

    退房编辑

  2. Checkin the file and Ignore server changes when prompted.

    检查文件并在出现提示时忽略服务器更改。

The reason why it failed for you is because you must have the "Get latest version of item on check out" option turned on. Turn this option off by going to Tools...Options...Source Control...Visual Studio Tema Foundation Server and unchecking "Get latest version of item on check out"

之所以失败是因为您必须打开“在结帐时获取项目的最新版本”选项。转到工具...选项...源控制... Visual Studio Tema Foundation Server并取消选中“在签出时获取项目的最新版本”,关闭此选项

Cheers

#3


18  

Rollback has been moved from tfpt.exe to tf.exe, the Team Foundation Version Control Tool.

回滚已从tfpt.exe移至tf.exe,Team Foundation版本控制工具。

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]]

#4


14  

You have two options for rolling back (reverting) a changeset in TFS 2010 Version Control. First option is using the User Interface (if you have the latest version of the TFS 2010 Power Tools installed).

在TFS 2010版本控制中,您有两个回滚(还原)变更集的选项。第一个选项是使用用户界面(如果您安装了最新版本的TFS 2010 Power Tools)。

如何回滚TFS签到?

The other option is using the TFS 2010 version control command-line application:

另一个选项是使用TFS 2010版本控制命令行应用程序:

tf.exe rollback

I have information about both approaches on my blog post available here: http://www.edsquared.com/2010/02/02/Rollback+Or+Undo+A+Changeset+In+TFS+2010+Version+Control.aspx

我在这里的博客文章中有关于这两种方法的信息:http://www.edsquared.com/2010/02/02/Rollback+Or+Undo+A+Changeset+In+TFS+2010+Version+Control.aspx

#5


14  

Another way to make your option 1 work is to reverse the order of the steps:

使您的选项1工作的另一种方法是颠倒步骤的顺序:

  1. Check Out the items
  2. 检查项目

  3. Get Specific Version to the old version
  4. 获取旧版本的特定版本

  5. Check in (ignoring the "warning server version is newer" dialog) OR on the conflicts section of the Pending Changes dialog resolve the conflicts by keeping the local version.
  6. 签入(忽略“警告服务器版本较新”对话框)或在“待定更改”对话框的“冲突”部分中,通过保留本地版本来解决冲突。

This will work even if you have Get Latest On Checkout set.

即使您在结帐时设置了最新信息,这也可以使用。

#6


5  

For reference, if you're using TFS 2010, here's the link to Rollback Command (Team Foundation Version Control) manual.

作为参考,如果您正在使用TFS 2010,这里是Rollback Command(Team Foundation版本控制)手册的链接。

To rollback a particular changeset, go to Visual Studio Command Prompt (2010), navigate to your TFS workspace directory, and type in command:

要回滚特定的变更集,请转到Visual Studio命令提示符(2010),导航到TFS工作空间目录,然后键入命令:

tf rollback /changeset:C12345

where 12345 is your changeset number. After this, it will show you the log of what it did and you'll have to sort out merge conflicts.

其中12345是您的变更集编号。在此之后,它将显示它所做的日志,你将需要解决合并冲突。

#7


4  

Ahh, just found this CodePlex Article on using TFPT.exe (power tool) to rollback a changeset.

啊,刚刚发现这篇关于使用TFPT.exe(电动工具)来回滚变更集的CodePlex文章。

Hope this helps you out.

希望这可以帮助你。

#8


4  

Not having a rollback option is actually feature of TFS ;)

没有回滚选项实际上是TFS的功能;)

To rollback changes:

要回滚更改:

  1. Check out whatever specific version of changes you want
  2. 查看您想要的任何特定版本的更改

  3. Edit->Select All->Copy the text in the file
  4. 编辑 - >全选 - >复制文件中的文本

  5. Checkout whatever version of the file is on the server
  6. 检查服务器上的文件版本

  7. Paste over the file and check in.
  8. 粘贴文件并签入。

And now all your intermediate changesets before the rollback are saved as well! What a great feature!

现在,在回滚之前的所有中间变更集都会被保存!真是太棒了!

#9


1  

If you did 1 check-in and you just want to undo it, that has a changeset # associated with it. Do a history on the folder in question to see the bad changeset. Open it up to see the details (all files changed, etc).

如果您执行了1次签到并且您只想撤消它,那么它具有与之关联的变更集#。对相关文件夹执行历史记录以查看错误的更改集。打开它以查看详细信息(所有文件已更改等)。

I believe that you can restore or undo a changeset from that screen, but my Visual Studio just crashed when I tried to do this. /sigh -- I definitely share your pain.

我相信您可以从该屏幕恢复或撤消变更集,但是当我尝试执行此操作时,我的Visual Studio刚刚崩溃。 /叹气 - 我绝对分享你的痛苦。

Where do I downmod TFS on this site?

我在哪里downmod TFS在这个网站上?

#10


1  

I think that the Team Foundation Power Tools is the way to go. If there are pending changes you can move them to a shelveset then undo or check in all pending changes before running the rollback command. See http://www.codeplex.com/VSTSGuidance/Wiki/View.aspx?title=How%20to%20undo%20a%20check-in&referringTitle=Source%20Control%20Practices%20at%20a%20Glance for more information.

我认为Team Foundation Power Tools是可行的方法。如果有挂起的更改,您可以将它们移动到shelveset,然后在运行rollback命令之前撤消或签入所有挂起的更改。有关详细信息,请参阅http://www.codeplex.com/VSTSGuidance/Wiki/View.aspx?title=How%20to%20undo%20a%20check-in&referringTitle=Source%20Control%20Practices%20at%20a%20Glance。

#11


1  

Ben Scheirman - the Changeset Details dialog does not have rollback functionality.

Ben Scheirman - “变更集详细信息”对话框没有回滚功能。

#12


1  

Another option is TFSPlus. This Visual Studio Addin adds (among others) Get This Version command to the history window. If you have the file checked out it will replace it with that version. If you do a check in afterwards you will effectively do a rollback to that version.

另一种选择是TFSPlus。此Visual Studio Addin将(获取此版本)命令添加到历史窗口中。如果您已检出文件,则会将其替换为该版本。如果您之后签入,则将有效地回滚到该版本。

It works on individual files instead of complete changesets, though.

但它适用于单个文件而不是完整的更改集。

#13


1  

using TFS powertools is the best way http://rajputyh.blogspot.com/2008/08/change-set-rollback-using-tfs-power.html

使用TFS powertools是最好的方法http://rajputyh.blogspot.com/2008/08/change-set-rollback-using-tfs-power.html

#14


1  

Get Specific Version

获取特定版本

In Version Type drop down select Type as Changeset

在Version Type下拉列表中,选择Type as Changeset

Use Changeset ... button to find your Changeset or just type in, if you know this number.

如果您知道此号码,请使用Changeset ...按钮查找您的Changeset或输入。

After you have the specific Changeset.

拥有特定的Changeset后。

Check Out

Check In

#15


0  

None of these solutions quite worked for me Dave Roberts solution was the closest to what I actually got working. I do not have Get latest version of item on check out enabled, however it seems to be a server policy.

这些解决方案对我来说都不起作用Dave Roberts解决方案是我最接近实际工作的解决方案。我没有在启用签出时获取最新版本的项目,但它似乎是一个服务器策略。

My solution to this is to check the file out for edit, get specific version, then when the conflict is detected use the merge tool (and manually merge none of the changes) so that the file is in the condition it was.

我的解决方案是检查文件以进行编辑,获取特定版本,然后在检测到冲突时使用合并工具(并手动合并任何更改),以使文件处于条件状态。

I was going to go with compare with the specific version and copy the entire file then just paste it over the top of the old one.

我将与特定版本进行比较并复制整个文件,然后将其粘贴到旧文件的顶部。

Still there should be an easier way to do this!

仍然应该有一个更简单的方法来做到这一点!

#16


0  

The solution above is for TFS2008. TFS2010 has built-in rollback feature. see this article for details.

上述解决方案适用于TFS2008。 TFS2010具有内置的回滚功能。有关详细信息,请参阅此文

#17


0  

Install the latest version of the TFS Power Tools (August 2011), and you can just right-click on a change set and select "Rollback Entire Changeset". It doesn't get much easier than that.

安装最新版本的TFS Power Tools(2011年8月),您只需右键单击更改集并选择“回滚整个变更集”。它并没有那么容易。

It's available here: http://visualstudiogallery.msdn.microsoft.com/c255a1e4-04ba-4f68-8f4e-cd473d6b971f

它可以在这里找到:http://visualstudiogallery.msdn.microsoft.com/c255a1e4-04ba-4f68-8f4e-cd473d6b971f

It's hinted at under Team Explorer Enhancements on the above page:

它在上面的网页资源管理器增强功能下暗示:

New in this release is the ability to [..] easily rollback changes in version control.

此版本中的新功能是[..]轻松回滚版本控制中的更改。

#1


63  

  1. Download and install Team Foundation Power Tools.
  2. 下载并安装Team Foundation Power Tools。

  3. Open up the Visual Studio command prompt
  4. 打开Visual Studio命令提示符

  5. Navigate to the directory on the file system that TFS is mapped to. If you don't do this you'll get an "Unable to determine the workspace" error when you try to roll back
  6. 导航到TFS映射到的文件系统上的目录。如果您不这样做,当您尝试回滚时,您将收到“无法确定工作区”错误

  7. Make sure everything else is checked in or shelved
  8. 确保其他所有内容都已签入或搁置

  9. run tfpt rollback to bring up the interface.
  10. 运行tfpt rollback以调出界面。

  11. Choose the changesets you want to rollback
  12. 选择要回滚的更改集

  13. Check in the new versions of the files you rolled back
  14. 签入您回滚的文件的新版本

The big disadvantage of the tool is that it will want to refresh everything in your workspace before you can merge. I got around this issue by creating a new workspace just for the rollback which mapped directly to the place in the source tree where the affected files were.

该工具的最大缺点是它需要在合并之前刷新工作区中的所有内容。我通过为回滚创建一个新工作区来解决这个问题,该工作区直接映射到受影响文件所在的源树中的位置。

If you need help to figure out which changesets to roll back, I find the code review tool in the free Team Foundation Side Kicks add-in very helpful.

如果您需要帮助来确定要回滚的更改集,我会发现免费的Team Foundation Side Kicks插件中的代码审查工具非常有用。

#2


24  

Your solution #1 will work: 1. manually get prior version of each file

您的解决方案#1将起作用:1。手动获取每个文件的先前版本

  1. check out for edit

    退房编辑

  2. Checkin the file and Ignore server changes when prompted.

    检查文件并在出现提示时忽略服务器更改。

The reason why it failed for you is because you must have the "Get latest version of item on check out" option turned on. Turn this option off by going to Tools...Options...Source Control...Visual Studio Tema Foundation Server and unchecking "Get latest version of item on check out"

之所以失败是因为您必须打开“在结帐时获取项目的最新版本”选项。转到工具...选项...源控制... Visual Studio Tema Foundation Server并取消选中“在签出时获取项目的最新版本”,关闭此选项

Cheers

#3


18  

Rollback has been moved from tfpt.exe to tf.exe, the Team Foundation Version Control Tool.

回滚已从tfpt.exe移至tf.exe,Team Foundation版本控制工具。

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]]

#4


14  

You have two options for rolling back (reverting) a changeset in TFS 2010 Version Control. First option is using the User Interface (if you have the latest version of the TFS 2010 Power Tools installed).

在TFS 2010版本控制中,您有两个回滚(还原)变更集的选项。第一个选项是使用用户界面(如果您安装了最新版本的TFS 2010 Power Tools)。

如何回滚TFS签到?

The other option is using the TFS 2010 version control command-line application:

另一个选项是使用TFS 2010版本控制命令行应用程序:

tf.exe rollback

I have information about both approaches on my blog post available here: http://www.edsquared.com/2010/02/02/Rollback+Or+Undo+A+Changeset+In+TFS+2010+Version+Control.aspx

我在这里的博客文章中有关于这两种方法的信息:http://www.edsquared.com/2010/02/02/Rollback+Or+Undo+A+Changeset+In+TFS+2010+Version+Control.aspx

#5


14  

Another way to make your option 1 work is to reverse the order of the steps:

使您的选项1工作的另一种方法是颠倒步骤的顺序:

  1. Check Out the items
  2. 检查项目

  3. Get Specific Version to the old version
  4. 获取旧版本的特定版本

  5. Check in (ignoring the "warning server version is newer" dialog) OR on the conflicts section of the Pending Changes dialog resolve the conflicts by keeping the local version.
  6. 签入(忽略“警告服务器版本较新”对话框)或在“待定更改”对话框的“冲突”部分中,通过保留本地版本来解决冲突。

This will work even if you have Get Latest On Checkout set.

即使您在结帐时设置了最新信息,这也可以使用。

#6


5  

For reference, if you're using TFS 2010, here's the link to Rollback Command (Team Foundation Version Control) manual.

作为参考,如果您正在使用TFS 2010,这里是Rollback Command(Team Foundation版本控制)手册的链接。

To rollback a particular changeset, go to Visual Studio Command Prompt (2010), navigate to your TFS workspace directory, and type in command:

要回滚特定的变更集,请转到Visual Studio命令提示符(2010),导航到TFS工作空间目录,然后键入命令:

tf rollback /changeset:C12345

where 12345 is your changeset number. After this, it will show you the log of what it did and you'll have to sort out merge conflicts.

其中12345是您的变更集编号。在此之后,它将显示它所做的日志,你将需要解决合并冲突。

#7


4  

Ahh, just found this CodePlex Article on using TFPT.exe (power tool) to rollback a changeset.

啊,刚刚发现这篇关于使用TFPT.exe(电动工具)来回滚变更集的CodePlex文章。

Hope this helps you out.

希望这可以帮助你。

#8


4  

Not having a rollback option is actually feature of TFS ;)

没有回滚选项实际上是TFS的功能;)

To rollback changes:

要回滚更改:

  1. Check out whatever specific version of changes you want
  2. 查看您想要的任何特定版本的更改

  3. Edit->Select All->Copy the text in the file
  4. 编辑 - >全选 - >复制文件中的文本

  5. Checkout whatever version of the file is on the server
  6. 检查服务器上的文件版本

  7. Paste over the file and check in.
  8. 粘贴文件并签入。

And now all your intermediate changesets before the rollback are saved as well! What a great feature!

现在,在回滚之前的所有中间变更集都会被保存!真是太棒了!

#9


1  

If you did 1 check-in and you just want to undo it, that has a changeset # associated with it. Do a history on the folder in question to see the bad changeset. Open it up to see the details (all files changed, etc).

如果您执行了1次签到并且您只想撤消它,那么它具有与之关联的变更集#。对相关文件夹执行历史记录以查看错误的更改集。打开它以查看详细信息(所有文件已更改等)。

I believe that you can restore or undo a changeset from that screen, but my Visual Studio just crashed when I tried to do this. /sigh -- I definitely share your pain.

我相信您可以从该屏幕恢复或撤消变更集,但是当我尝试执行此操作时,我的Visual Studio刚刚崩溃。 /叹气 - 我绝对分享你的痛苦。

Where do I downmod TFS on this site?

我在哪里downmod TFS在这个网站上?

#10


1  

I think that the Team Foundation Power Tools is the way to go. If there are pending changes you can move them to a shelveset then undo or check in all pending changes before running the rollback command. See http://www.codeplex.com/VSTSGuidance/Wiki/View.aspx?title=How%20to%20undo%20a%20check-in&referringTitle=Source%20Control%20Practices%20at%20a%20Glance for more information.

我认为Team Foundation Power Tools是可行的方法。如果有挂起的更改,您可以将它们移动到shelveset,然后在运行rollback命令之前撤消或签入所有挂起的更改。有关详细信息,请参阅http://www.codeplex.com/VSTSGuidance/Wiki/View.aspx?title=How%20to%20undo%20a%20check-in&referringTitle=Source%20Control%20Practices%20at%20a%20Glance。

#11


1  

Ben Scheirman - the Changeset Details dialog does not have rollback functionality.

Ben Scheirman - “变更集详细信息”对话框没有回滚功能。

#12


1  

Another option is TFSPlus. This Visual Studio Addin adds (among others) Get This Version command to the history window. If you have the file checked out it will replace it with that version. If you do a check in afterwards you will effectively do a rollback to that version.

另一种选择是TFSPlus。此Visual Studio Addin将(获取此版本)命令添加到历史窗口中。如果您已检出文件,则会将其替换为该版本。如果您之后签入,则将有效地回滚到该版本。

It works on individual files instead of complete changesets, though.

但它适用于单个文件而不是完整的更改集。

#13


1  

using TFS powertools is the best way http://rajputyh.blogspot.com/2008/08/change-set-rollback-using-tfs-power.html

使用TFS powertools是最好的方法http://rajputyh.blogspot.com/2008/08/change-set-rollback-using-tfs-power.html

#14


1  

Get Specific Version

获取特定版本

In Version Type drop down select Type as Changeset

在Version Type下拉列表中,选择Type as Changeset

Use Changeset ... button to find your Changeset or just type in, if you know this number.

如果您知道此号码,请使用Changeset ...按钮查找您的Changeset或输入。

After you have the specific Changeset.

拥有特定的Changeset后。

Check Out

Check In

#15


0  

None of these solutions quite worked for me Dave Roberts solution was the closest to what I actually got working. I do not have Get latest version of item on check out enabled, however it seems to be a server policy.

这些解决方案对我来说都不起作用Dave Roberts解决方案是我最接近实际工作的解决方案。我没有在启用签出时获取最新版本的项目,但它似乎是一个服务器策略。

My solution to this is to check the file out for edit, get specific version, then when the conflict is detected use the merge tool (and manually merge none of the changes) so that the file is in the condition it was.

我的解决方案是检查文件以进行编辑,获取特定版本,然后在检测到冲突时使用合并工具(并手动合并任何更改),以使文件处于条件状态。

I was going to go with compare with the specific version and copy the entire file then just paste it over the top of the old one.

我将与特定版本进行比较并复制整个文件,然后将其粘贴到旧文件的顶部。

Still there should be an easier way to do this!

仍然应该有一个更简单的方法来做到这一点!

#16


0  

The solution above is for TFS2008. TFS2010 has built-in rollback feature. see this article for details.

上述解决方案适用于TFS2008。 TFS2010具有内置的回滚功能。有关详细信息,请参阅此文

#17


0  

Install the latest version of the TFS Power Tools (August 2011), and you can just right-click on a change set and select "Rollback Entire Changeset". It doesn't get much easier than that.

安装最新版本的TFS Power Tools(2011年8月),您只需右键单击更改集并选择“回滚整个变更集”。它并没有那么容易。

It's available here: http://visualstudiogallery.msdn.microsoft.com/c255a1e4-04ba-4f68-8f4e-cd473d6b971f

它可以在这里找到:http://visualstudiogallery.msdn.microsoft.com/c255a1e4-04ba-4f68-8f4e-cd473d6b971f

It's hinted at under Team Explorer Enhancements on the above page:

它在上面的网页资源管理器增强功能下暗示:

New in this release is the ability to [..] easily rollback changes in version control.

此版本中的新功能是[..]轻松回滚版本控制中的更改。