1

I have a bunch of files in the 'added' state across many folders that were accidentally deleted from the file system. How can I easily either undo them or convert all of them to a 'delete' status? I'd prefer not to have to manually undo each file one at a time.

What I've tried so far:

  • In the Pending Changes window, using the Undo command for each missing file is tedious. Since the window does not identify which files are missing, I have to compare this window to the file explorer and compare the contents of each folder.
  • The answers for this similar question don't apply to me because my files are in the 'added' state, so comparing my workspace to the server will not identify these missing files.
  • I've looked through the TFS Power Tools for something to identify missing files but haven't found anything that directly addresses missing files.
  • The tfpt online command doesn't address missing files in the 'added' state.
Community
  • 1
  • 1
Keith
  • 20,636
  • 11
  • 84
  • 125
  • Downvote because this question does not show any research effort. Have you taken a look at any of the related SO links, like [this](http://stackoverflow.com/questions/7127985/deleted-a-file-out-side-visual-studio-tfs-doesnt-recognize-it?rq=1) or [this](http://stackoverflow.com/questions/2770727/how-do-i-remove-files-from-the-pending-changes-list-in-tfs-when-those-files-have?rq=1)? – admdrew Jan 13 '15 at 18:29
  • @admdrew Yes I did and neither help. One involves files already added (I'm dealing with files in the 'added' state so the solution doesn't apply), the other involves manually undoing each file one at a time which as stated above I'm trying to avoid. – Keith Jan 13 '15 at 18:33

2 Answers2

2

If I read you correctly, in this case your underlying file system and what TFS thinks is on your file system have gotten out of sync.

The best, easiest, way I know how to rectify this is to undo all your changes, then redo the adds, deletes, and edits that you actually require. I know that with many files this will be a pain, but let me reiterate: I mean the best, easiest way and not the fun, effortless way (which I don't think exists)!

Do a 'clean' in your project within Visual Studio, then delete any bin/ and obj/ folders in the source.

Then undo all changes for your project.

If you are using TFS < 2013, I would recommend the use of Team Foundation Power Tools online functionality. For instance:

cd \dev\path\to\project\root\
tfpt online /adds /diff /deletes /recursive .

Otherwise, if you are using TFS 2013, then you can use the built-in 'reconcile' functionality (cannot find a web URL for this, the 2010 docs are incorrect, use 'tf reconcile /?' for a description):

cd \dev\path\to\project\root\
tf reconcile /adds /deletes /diff /recursive /noignore /promote .
d3r3kk
  • 3,465
  • 3
  • 18
  • 22
1

With TFS Power Tools installed, run this command from a VS command prompt in the appropriate folder:

tf reconcile /deletes /diff /recursive /noignore /promote

This will display a list of pending changes. The missing files will all be selected with a new status of 'delete'. Click Promote to save the change, then try again to check in.

This is a slight variation of d3r3kk's answer but without the /add flag which causes more files to be selected than necessary.

Keith
  • 20,636
  • 11
  • 84
  • 125