how to undo pending changes of files that are unchanged?

五迷三道 提交于 2019-12-09 02:51:17

问题


One thing that drives me crazy with TFS is the fact that if you have a file checked out, but you made no changes to it, it still shows as a change, distracting you from real changes that you made. This is especially annoying when you use tools such as T4 to generate code, because most of the time the tool will generate the same code, but will leave the file checked out.

For some reason that I can't understand, Visual Studio insists in showing those as changes, and will even claim that there are conflicts if another person happened to check-in the same "changes".

Fortunately, the TFS Power Tools include a command that compares checked-out files with the server version and undoes the unchanged files. I will explain how to integrate it into Visual Studio using a custom tool.

This is unfortunately not available if you are using Visual Studio 2017!

It used to be very simple to accomplish this with earlier versions of Visual Studio:

tfpt uu /noget /r *

How do we remove files from pending changes if they do not have any changes?


回答1:


This is different based upon your choice of version control system in TFS, so the above problem only exists for TFS' traditional version control system TFVC and not git which has been supported for a few years now.

For TFVS a partial workaround is to mark all files, right-click and Undo... and click Undo Changes button in the following dialog. This will prompt you for the files that are different (letting you choose No or No to All) but not for the ones that have no changes. Important: I write 'partial' because this approach does not work for file renames as the file is considered unchanged so the rename will be undone.




回答2:


Yes,there are no Power Tools for Team Foundation Server 2017. You could use below workaround:

Right-click on your project ,select undo checkout, then just click okay, or whatever confirmation is left...

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

You could also take a look at this question: his question Files listed as pending changes when doing merges that didn't change?




回答3:


The TFSSourceControlExplorerExtension extension is available for VS 2017 and it has an undo unchanged action that works rather nicely.



来源:https://stackoverflow.com/questions/46657465/how-to-undo-pending-changes-of-files-that-are-unchanged

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!