Jeroen
Jeroen

Reputation: 63729

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:

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?

Upvotes: 1

Views: 111

Answers (2)

Jeroen
Jeroen

Reputation: 63729

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.

Upvotes: 1

Vicky - MSFT
Vicky - MSFT

Reputation: 5010

If that file is already added to TFS Version Control, you need to run tf destroy command to delete it permanently from TFS server.

And, you need to create one .tfignore file to exclude one specific file during checking in. See: https://msdn.microsoft.com/en-us/library/ms245454.aspx#tfignore and http://blog.appliedis.com/2014/11/06/excluding-files-from-team-foundation-version-control-using-tfignore-files/

Upvotes: 1

Related Questions