TFS:如何撤消批处理文件中未修改文件的签出

发布于 2024-07-13 13:00:45 字数 228 浏览 6 评论 0原文

我们使用批处理文件来生成代码,它会自动从 Team Foundation Server (TFS) 中检出生成的文件,以便重新生成它们。 这些文件中的大多数都没有被修改,但生成器事先并不知道这一点。

“tfs undo”命令撤消签出,但会提示是否修改了某些内容(我们不想这样做)。 我们也不想立即签入生成的文件。

是否有一个命令(或一系列命令)可以在不提示用户的情况下撤消所有未修改文件的签出?

We use a batch file to generate code, and it automatically checks out the generated files from Team Foundation Server (TFS) so that it can regenerate them. The majority of these files are not modified, but the generator does not know this ahead of time.

The "tfs undo" command undoes the checkout, but prompts if some have been modified (which we don't want to do). We also do not want to check in the generated files right away.

Is there a command (or series of commands) to undo checkout of all unmodified files without prompting the user?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(12

半暖夏伤 2024-07-20 13:00:45

查看 2011 年 8 月的 Team Foundation Server Power Tools< 的 Undo Unchanged 命令< /a>

c:\myProject> tfpt uu . /noget /recursive

感谢 Matt Florence 更新链接。

感谢 Ray Vega 提供实际语法 .

Take a look on Undo Unchanged command of the Team Foundation Server Power Tools August 2011

c:\myProject> tfpt uu . /noget /recursive

Thanks Matt Florence for link update.

Thanks Ray Vega for actual syntax.

舟遥客 2024-07-20 13:00:45

安装 Team Foundation Server Power Tools 并使用以下命令从命令行运行以下命令tfpt.exe 位于项目工作区目录的根目录:

c:\myProject> tfpt uu 。 /noget /recursive

强烈建议包括 /noget ,因为它可以防止强制“获取最新”所有项目文件,这取决于总数可能需要很长时间。

Install Team Foundation Server Power Tools and run the following from the command line using tfpt.exe at the root of your project's workspace directory:

c:\myProject> tfpt uu . /noget /recursive

Including /noget is highly recommended since it prevents a forced 'get latest' of all your project's files which depending on the total number can take a extremely long time.

梦里泪两行 2024-07-20 13:00:45

谢谢@mike & @ray,

我希望让它变得更容易。

在 VS 中,在“工具”菜单中,单击“外部工具”。

外部工具

单击添加。

输入标题。

命令:tfpt.exe

参数:uu 。 /noget /recursive

初始目录:[可以通过箭头按钮选择]。

撤消解决方案中的未更改

撤消项目中的未更改

“工具”菜单中添加了两个新命令。

需要时使用它们。

享受吧,

奥菲尔

Thank you @mike & @ray,

I wish to make it easier.

In VS, at Tools menu, click on "External Tools".

External Tools

Click Add.

Enter title.

Command: tfpt.exe

Arguments: uu . /noget /recursive

Initial Directory: [you can choose from the arrow button].

Undo unchanged in solution

Undo unchanged in project

Two new command are added to Tools menu.

Use them when needed.

Enjoy,

Ofir

爺獨霸怡葒院 2024-07-20 13:00:45
  1. 右键单击您的项目
  2. ,选择“撤消签出”,然后单击“确定”,或者留下任何确认信息...
  3. 然后,在撤消签出时,对于其中有实际更改的每个文件,都会出现提示,要求您确认签出该文件...只需单击“全部否”,

Visual studio 就会知道签出的文件是否已更改或没有更改。

警告:此方法还会删除文件,即尚未签入到 TFS 的文件。 如果您想保留这些文件,只需将它们从您“撤消”的文件集中排除即可。

  1. Right-click on your project
  2. Select undo checkout, then just click okay, or whatever confirmation is left...
  3. Then, while undoing checkout, for every file that has REAL changes in it, a prompt will ask you to confirm the check out for that file... simply click "No to All"

Visual studio will know if the checked out file has changes or none.

WARNING: This method also removes new files, i.e. files that are not yet checked in to TFS. If you want to keep these files then simply exclude them from the set of files you "undo".

你列表最软的妹 2024-07-20 13:00:45

仅使用 TFS2017VS2017/VS2019 时的答案更新了此问题。

TFS 2017 不存在强大的工具,旧的工具不能与它很好地协同工作,但显然大部分功能已转移到 VS2017 本身或插件(见下文)。

Visual Studio 2017/2019 扩展

某些操作(例如撤消未更改的文件)已移至

VS2017 的 扩展

VS2019 扩展

“撤消未更改”按钮位置:

< img src="https://i.sstatic.net/wqYDr.png" width="300" alt="撤消未更改的按钮位置">

已知错误

您必须打开“源代码管理资源管理器”(并将其保持打开状态)以便“撤消未更改”显示在“待处理更改”视图的“操作”菜单中。
在此处报告

Windows Shell 集成扩展

此外,您仍然可以通过单独的设置 Windows Shell 集成安装程序 不再链接到 TFS Power Tools。

Windows shell 集成的工作方式与之前的 powertools 并不完全相同,但最重要的操作对我来说很有效。

Updated this question with an answer when working with TFS2017 and VS2017/VS2019 only.

The power tools does not exist for TFS 2017 and the old ones can't work well together with it, but apparently most of the functionality has been moved to VS2017 itself or plugins (see below).

Visual Studio 2017/2019 Extension

Some actions like undo unchanged files have moved to an

extension for VS2017

extension for VS2019

"Undo Unchanged" button location:

undo unchanged button location

Known bug

You have to open the 'Source Control Explorer' (and leave it open) so that the 'Undo Unchanged' is displayed in the Action menu of the Pending Changes view.
reported here.

Windows Shell Integration Extension

Also, you can still set up Windows shell integration through an separate installer which is no longer linked to TFS Power Tools.

The windows shell integration do not work exactly the same as the powertools before, but the most important actions worked for me.

一个人的旅程 2024-07-20 13:00:45

如果您只需再次签入所有已签出的文件,TFS 就会足够智能地找出哪些文件发生了更改,并仅将它们包含在服务器上记录的变更集中。

TFS 通过比较签入前后文件内容的 MD5 哈希来实现此目的。

这一切都假设您的生成过程纯粹是更新同一组文件,即您永远不会遇到下一代不需要上一代生成的文件的情况(即您希望挂起删除)对于该文件)或文件更改名称。

如果您的进程可能需要删除文件,那么最好的选择可能是查看 Team Foundation Power Tools 命令 (tfpt) 并使用tfpt online 命令只会检查已更改的文件,并且足够智能,可以挂起删除不再需要的任何文件或更改名称和挂起添加。

祝你好运,

马丁。

If you simply check all the files back in again that you checked out, TFS is smart enough to figure out which ones changes and only include them in the changeset that is recorded on the server.

TFS does this by comparing MD5 hashes of the files contents before and after check-in.

This is all assuming that your generation process is purely updating the same set of files, i.e. you will never have the case where a file that was generated in a previous generation is not needed in the next generation (i.e. you would want to pend a delete for that file) or that the files change name.

If your process could potentially need files deleting, the your best bet might be to look at the Team Foundation Power Tools command (tfpt) and use the tfpt online command that will only check out the files that have changed, and will be smart enough to pend deletes for any files that are no longer needed or changed name and pend adds.

Good luck,

Martin.

绳情 2024-07-20 13:00:45

请注意,TFS 撤消不会恢复文件系统的“修改日期”值。 这是非常令人沮丧的,尤其是当您使用 robocopy 等工具来同步远程计算机时。 即使在撤消签出之后,如果您保存了文件从而更新了“修改日期”值,则即使在撤消签出之后,更新后的值也会保留下来。

Beware that TFS undo will not revert back the File System's "Date Modified" value. This is very frustrating especially if you use tools like robocopy to sync up remote machines. Even after you undo your check out, if you saved the file thereby updaing the "Date Modified" value, that updated value will stick around even after an undo checkout.

青萝楚歌 2024-07-20 13:00:45

关于 tfpt 的 uu 选项(在大多数其他答案中推荐),有几点一开始我并不清楚。 首先,这是命令行帮助,可以使用命令 tfpt uu /? 访问

撤消多余的挂起更改。 如果项目的状态带有
待处理的更改与服务器上的相同,则更改为
已撤消。

用法:tfpt uu [/changeset:changesetnum] [/recursive] [/noget]
[文件规格...]

  • /changeset 将工作区与指定变更集版本而不是最新版本的项目状态进行比较
  • 文件规范...仅检查列出的文件规范是否存在冗余更改
  • /recursive 使用完全递归检查指定的文件规范
  • /noget 在检查之前不要运行 get

/changeset 选项不能与文件规范或 /recursive 一起使用。

现在让我分解一下其他答案中推荐的命令。

tfpt uu . /noget /recursive
  • tfpt uu 指定我们希望使用“Undo Unchanged”命令。
  • . 指示(我猜)当前工作目录应用作文件规范。
  • /noget 确保在撤消未更改的文件之前不会调用“获取最新版本”。
  • /recursive 确保不仅考虑文件规范,而且考虑所有递归子文件夹和文件。 这似乎取决于文件规范 - 如果没有提供,则处理整个工作区。

因此,关于上面的命令,这里有一些需要注意的事情......

  • 它取决于工作目录。
  • 它不处理整个工作区。

我发现以下命令最适合我 - 它将处理整个工作区。

tfpt uu /noget

请注意,它仍然依赖于工作目录,因为 tfpt 使用它来确定应处理哪个工作空间。 但只要您提供工作区中文件或文件夹的路径,就可以开始了。

There are a couple of points regarding the uu option for tfpt (recommended in most of the other answers) that were not clear to me at first. Firstly, this is the command line help that can be accessed with the command tfpt uu /?

Undoes redundant pending changes. If the state of an item with a
pending change is the same as on the server, then the change is
undone.

Usage: tfpt uu [/changeset:changesetnum] [/recursive] [/noget]
[filespec...]

  • /changeset Compare the workspace to item states at the changeset version specified instead of the latest version
  • filespec... Only check the listed filespecs for redundant changes
  • /recursive Check the specified filespecs with full recursion
  • /noget Do not run get before checking

The /changeset option may not be used with filespecs or /recursive.

Now let me break down the command that is recommended in the other answers.

tfpt uu . /noget /recursive
  • tfpt uu specifies that we wish to use the 'Undo Unchanged' command.
  • . indicates (I guess) that the current working directory should be used as the filespec.
  • /noget ensures that 'get latest version' is not called before undoing the unchanged files.
  • /recursive ensures that not just the filespec will be considered but all recursive child folders and files. This seems to be dependent on the filespec - if there is none provided then the whole workspace is processed.

So there are a couple of things to note here regarding the command from above...

  • It is dependent on the working directory.
  • It does not process the entire workspace.

I have found that the following command works best for me - it will process the entire workspace.

tfpt uu /noget

Note that it is still dependent on the working directory in that tfpt uses it to determine which workspace should be processed. But as long as you provide a path to a file or folder within the workspace, you are good to go.

时光瘦了 2024-07-20 13:00:45

我可以在上面看到 Ray LionFang 的方法。 由于我没有代表,因此无法发表评论。 虽然我喜欢这种方法,因为不需要对工具等进行任何更改......

  1. 右键单击您的项目
  2. 选择撤消结账,然后单击“确定”,或者留下任何确认信息...
  3. 然后,在撤消操作时
    签出,对于其中有实际更改的每个文件,都会出现提示
    要求您确认签出该文件...只需单击“否”
    全部”
  4. Visual Studio 将知道签出的文件是否已更改或
    没有任何。 请注意,此方法还会删除未添加的文件
    尚未从 TFS 签入...

....该方法存在一个问题,即点击“全部否”会保留一些未修改的文件。 它似乎会执行诸如“撤消未修改的文件”之类的操作,直到它到达实际修改的第一个文件,然后忽略其余未修改的文件(如果这有意义)。 这种效果我只偶尔见过一次。

一个可能的解决方法是遵循上述过程,但不要对每个文件单击“否”,而是单击“否”。 由于这可能需要一段时间,具体取决于您正在处理的文件数量,因此我通常所做的是按住“ALT + N”,它只是加速浏览所有文件,同时撤消所有未修改的文件。

I can see Ray LionFang's approach above. Can't comment there since I don't have the rep. While I like this approach since there's no changes required to Tools etc........

  1. Right-click on your project
  2. select undo checkout, then just click okay, or whatever confirmation is left...
  3. then, while undoing
    checkout, for every file that has REAL changes in it, a prompt will
    ask you to confirm the check out for that file... simply click "No to
    All"
  4. Visual studio will know if the checked out file has changes or
    none. Be aware that this method also removes added files that are not
    yet checked in from TFS...

.......there's a problem with that approach in that hitting "No To All" retains a few files which are not modified. It seems to do something like Undoing unmodified files until it hits the first file that's actually modified and then ignores the rest of the unmodified files, if that makes any sense. I've only seen this effect once in a while.

A potential work-around is to follow the above process but instead of hitting "No To All", hit "No" for each file. Since this can take a while depending on the number of files you're working with, what I normally do is to hold down "ALT + N", and it just speeds through all the files while undoing ALL unmodified files.

┈┾☆殇 2024-07-20 13:00:45

我来晚了一点,但是如果您可以控制批处理脚本,您可以在生成过程中检查任何文件,然后运行以下内容:

tf reconcile [path-to-local-folder] /promote /adds /deletes /recursive

以确保您签出您想要签入的文件。 您可以在此处阅读有关协调命令及其语法的更多信息:

https://learn.microsoft.com/en-us/azure/devops/repos/tfvc/reconcile-command

I'm a bit late to the party, but if you have control over the batch script you could simply not check out any files during the generation process and then run something along the lines of:

tf reconcile [path-to-local-folder] /promote /adds /deletes /recursive

to make sure you check out only the files you intend to check-in. You can read more about the reconcile command and its syntax here:

https://learn.microsoft.com/en-us/azure/devops/repos/tfvc/reconcile-command

马蹄踏│碎落叶 2024-07-20 13:00:45

我发现既不会导致 Visual Studio 崩溃也不会花费很长时间的最安全、最快的方法是:

1- 打开开发人员命令提示符。 您可以从 Visual Studio 中执行此操作,在顶部的搜索字段中键入开发人员命令提示符。

2- 使用以下命令获取所有签出文件的状态:

tf status "$/" /s:tfs /recursive /format:detailed

3- 然后您将获得与以下内容类似的项目列表:
输入图片这里的描述

然后复制你想要批量撤消img中从1开始的所有内容的目录路径。 在下面的命令中将其填入双引号之间,而不是 PUT_1_HERE。 对 2 和 3 执行相同的操作(不带双引号)。

tf undo "PUT_1_HERE" /workspace:PUT_2_HERE;PUT_3_HERE /recursive

4- 执行命令,瞧,无论要撤消的文件数量有多大,都需要几秒钟的时间。

The safest and fastest way I found which neither causes Visual Studio to crash nor takes a long time is:

1- Open the developer command prompt. You can do that from Visual Studio, type developer command prompt in the search field at the top.

2- get the status of all checkouted files using the following command:

tf status "$/" /s:tfs /recursive /format:detailed

3- Then you'll get a list of similar items to the following:
enter image description here

Then copy the path of the directory you want to batch undo everything under from 1 in the img. Fill in that in the command below between the double quotations instead of PUT_1_HERE. Do the same for 2 and 3 without double quotations.

tf undo "PUT_1_HERE" /workspace:PUT_2_HERE;PUT_3_HERE /recursive

4- Execute the command and Voila it should take some seconds regardless how large the number of files to undo is.

无所谓啦 2024-07-20 13:00:45

据我了解,在 TFS 中,如果您签出团队项目,则会签出整个项目,并且您无法控制哪些文件被删除。 如果您想阻止签入某些文件,您可以锁定它们。

在工作中,我们都讨厌 TFS。

As far as I understood, in TFS if you checkout a team project, the whole project is checked out and you do not have control of which files are brought down. If you want to prevent checkins to certain files, you can lock them.

At work, we all hate TFS.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文