Search code examples
visual-studiovisual-studio-2013tfstfvc

Forget and Ignore a file in TFS while keeping it locally and in the project


I have a file that is currently:

  1. Present in the TFS 2013 repository;
  2. Included in the Visual Studio 2013 project;
  3. And as such it's obviously also present on disk;

Previously, with Mercurial, I could just:

  • hg forget to remove it from version control;
  • add that file to my ignore pattern;

And all would be well. People that do a fresh/clean clone will see that file as "missing", which was exactly the point: everyone had (needed, even) his own local version of that file.

How do I emulate this with TFS? That is, how can I make sure:

  1. The file is not present anymore in TFS 2013 repository;
  2. The file is still included in the Visual Studio 2013 project;
  3. The file might be present on disk if the user had created one;

Can I accomplish this with Visual Studio 2013? Do I need to dive into the command line?


Solution

  • In the end what I did was this:

    1. Copy-paste "backup" of the file;
    2. Delete the file from the solution explorer;
    3. Put the "backup" back in the original file's location;
    4. Edit the csproj (e.g. in Notepad) and revert the change done by TFS during step 2;
    5. Check in these changes;

    Warning: this does remove the file for others that currently have it. The file will show as "missing" for them after getting the latest updates from TFS. They will need to manually restore the file at that location (e.g. from an old version, or freshly created).

    I don't think this is the proper way to do this, probably @Vickey's answer (i.e. use TFS command line and ignore files properly) is the correct way to do it. I just haven't gotten around to trying it yet. But this answer does work.