用户删除文件并创建同名新文件时 TFS 回滚
有人(除了我自己)意外删除了 TFS 中的文件并将其签入。然后他发现了自己的错误并想要替换丢失的文件,他做到了 - 从他自己的硬盘驱动器。 在他的错误和我发现它之间,其他人对相邻文件进行了更改。 现在,我想将已删除的文件回滚到删除之前的状态,但是当我尝试时,我在原始文件和替换文件之间(如果我理解正确的话)出现文件名冲突错误。
我无法回滚整个项目,因为已经完成了其他工作,我只想将这些文件恢复到“之前”的状态。
有人遇到过这个问题并解决了吗?或者说没有解决办法。
Someone (other than myself) accidentally deleted files in TFS and checked it in. He then discovered his error and wanted to replace the lost files, which he did - from his own hard drive.
In between his error and my discovery of it, others have made changes to adjacent files.
Now, I want to roll the deleted files back to their state before the delete, but when I try I get a filename collision error between (if I understand it correctly) the original files and his replacements.
I can't roll the entire project back since there has been other work done, I just want to get these files back to how they were "before".
Has anyone had this problem and solved it? Or is there no solution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
感谢大家的意见。
为了供将来参考,这就是我最终解决此问题的方法:
首先,我获取了该文件的本地副本。
然后,在源代码管理资源管理器中,我将包含该文件的文件夹回滚到旧文件已被删除但新文件尚不存在的变更集。
我取消删除了该文件并签入,从而“从远处”带回了原始文件。
之后,几乎就是将我的本地副本和恢复的文件放入 diff 工具(我使用 BeyondCompare BTW)并更正恢复的文件以匹配新版本。
我可以这样做有几个原因,即:
我不知道如果我们没有错过有问题的文件,直到几周后,我们会对周围的代码进行一些更改,那么会发生什么。我也不知道对本地版本所做的任何实质性更改对可恢复性意味着什么。
Thank you all for your input.
For future reference, this is how I finally solved the case:
Firstly, I took a local copy of the file.
In Source Control Explorer, I then rolled back the folder containing the file to the changeset where the old file had been deleted but the new file was not yet present.
I undeleted the file and checked in, thus bringing the original back "from beyond".
After that, it was pretty much a case of putting my local copy and the recovered file into a diff tool (I used BeyondCompare BTW) and correct the recovered file to match the new version.
I could do this due to a couple of reasons, namely:
I have no idea what would have happened if we for instance hadn't missed the file in question until a couple of weeks later, where we would have had several changes made to the surrounding code. I also have no clue as to what any substantial changes made to the local version had meant in terms of recoverability.
我在这里看到的唯一问题是您可能会丢失已删除文件的历史记录。
Only problem I can see here, is you may lose history on the deleted file.
听起来像是Power Tools的工作。给你:
正如评论中提到的,在理想的 Powershell 世界中,最终管道中丑陋的字符串解析应该是不必要的。如果事情按预期进行,您可以删除该行(或者等效地,将其替换为 Select-TfsItem | )。不幸的是,电动工具似乎无法按照我的预期处理删除 ID。
无论如何,这个脚本应该满足您的要求。注意:
Sounds like a job for the Power Tools. Here you go:
As alluded to in the comment, the ugly string parsing in the final pipeline shouldn't be necessary in an ideal Powershell world. If things worked as intended, you could remove that line (or equivalently, replace it with Select-TfsItem | ). Unfortunately, the Power Tools don't appear to handle deletion IDs as well as I intended them to.
Anyway, this script should do what you asked. Notes: