15

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?

Alex Gordon
  • 57,446
  • 287
  • 670
  • 1,062
  • I can write up an answer soon -- but it's possible to install TFPT (2015) anyway and still use it -- basically you need to install it the first time (it will succeed but install nothing), and then a second time, you click "modify" and go through each feature and explicitly install it anyway. -- Then you need to do some config to make the authentication work, and you're good to go. /HTH – BrainSlugs83 May 16 '18 at 22:33

4 Answers4

18

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.

Tore Østergaard
  • 4,362
  • 3
  • 27
  • 43
12

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?

PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62
  • 1
    we're using tfs 2013 and vs 2017. you are suggesting to go to every one of our 150 projects and click on undo checkout? – Alex Gordon Oct 10 '17 at 12:22
  • @l--''''''---------'''''''''''' Haven't tried if it works for multiple projects due to out of work, but I'm sure it works well on my side for a single project. You could try to do this for both a single project and multiple projects. For multiple projects, when undo your pending changes in team explorer. once you get the confirmation dialog choose "No to all" – PatrickLu-MSFT Oct 10 '17 at 12:35
  • 2
    i've got 1500 pending changes, so far it's been stuck on this for 20 minutes trying to undo pending changes after clicking no to all – Alex Gordon Oct 10 '17 at 12:44
  • Is there any reason (that does not include git) that you know of why this isnt present? I'm missing my fav "Unshelve to another branch" tool also. Not having those two tools cost me about 4-6 days of effort last year.. – StingyJack Sep 03 '18 at 04:43
5

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

Brian
  • 1,803
  • 1
  • 16
  • 22
StingyJack
  • 19,041
  • 10
  • 63
  • 122
  • 2
    Note that you need the Source Control Explorer window open while looking at your pending changes to see "Undo Unchanged" in the Actions menu (pending changes window). – Brian Oct 16 '18 at 14:58
  • And sometimes you need to close and reopen VS if you have executed it once already. Even with that its faster than the alternative. – StingyJack Oct 16 '18 at 18:50
0

Stage the change you actually want. The file that isn't actually changed then disappears.

Gail Foad
  • 623
  • 10
  • 22