5

I have seen other posts and read them on stackoverflow - How to ignore files/directories in TFS for avoiding them to go to central source repository?

However this does not seem to work.

I have a folder of the root called /FS which in that directory I have the following .tfignore

    ################################################################################
# This .tfignore file was automatically created by Microsoft(R) Visual Studio.
#
# Local items matching filespecs in this file will not be added to version
# control. This file can be checked in to share exclusions with others.
#
# Wildcard characters are * and ?. Patterns are matched recursively unless the
# pattern is prefixed by the \ character.
#
# You can prepend a path to a pattern to make it more specific. If you do,
# wildcard characters are not permitted in the path portion.
#
# The # character at the beginning of a line indicates a comment.
#
# The ! prefix negates a pattern. This can be used to re-include an item after
# it was excluded by a .tfignore file higher in the tree, or by the Team
# Project Collection's global exclusions list.
#
# The / character is interpreted as a \ character on Windows platforms.
#
# Examples:
#
#  # Excludes all files ending in .txt in Alpha\Beta and all its subfolders.
#  Alpha\Beta\*.txt
#
#  # Excludes all files ending in .cpp in this folder only.
#  \*.cpp
#
#  # Excludes all files ending in .cpp in this folder and all subfolders.
#  *.cpp
#
#  # If "Contoso" is a folder, then Contoso and all its children are excluded.
#  # If it is a file, then only the "Contoso" in this folder is excluded.
#  \Contoso
#
#  # If Help.exe is excluded by a higher .tfignore file or by the Team Project
#  # Collection global exclusions list, then this pattern re-includes it in
#  # this folder only.
#  !\Help.exe    
#
################################################################################

\BRAND
\CO
\COVER
\COVERBANNER
\DEPT
\DEPT-CATS
\LIB
\PRODUCTS

However, TFS keeps trying to add these directories. I even have at the root directory another .tfignore

/FS

I simply need /FS out of TFS. This is 15GB workth of images that does not belong in SOURCE control, we have multiple areas where these images are backed up and this is very resource intense creating branches.

Do I need to delete the /FS from TFS with CMD PROMPT? Any help would be great. I am simply frustrated and stuck.

Community
  • 1
  • 1
Moojjoo
  • 729
  • 1
  • 12
  • 33
  • 2
    As far as I know, this only works with Local Workspaces. [link](https://msdn.microsoft.com/en-us/library/bb892960.aspx) – Alistair Mackay Jul 07 '15 at 15:03
  • Please expand on this comment, I am unsure if I understand. – Moojjoo Jul 07 '15 at 15:04
  • What is causing the Adds? Normally these would appear as things that need to be promoted if the Ignore wasn't working? Can you not undo the pending changes, then right click in the "Promote" dialog and select exclude this folder? – DaveShaw Jul 07 '15 at 22:14
  • @Moojjoo, the previous comment is saying, if your workspace is configured as "Server" ignore files don't work, You can check your workspace settings from the "Workspaces..." option in the combo at the top of source control explorer. – DaveShaw Jul 07 '15 at 22:15
  • @Moojjoo previous comments ask you a critical info. You have different techniques to exclude files from VC (surgical mapping, cloacking, tfignore, VC configuration). You should explain: your kind of Workspace (local or server), the mapping (default single mapping to $/ ?) and the type of files you like to include, exclude (want to exclude all .avi?). Enrich your question and we can give useful answers – Giulio Vian Jul 09 '15 at 12:51
  • I am doing some major surgery on the entire TFS source control and will post back when I am done. – Moojjoo Jul 09 '15 at 13:12
  • DaveShaw --- There are 100+++ of directories and images in the folder and TFS is always trying to add them to source control. I simply need TFS to ignore the directory. – Moojjoo Jul 09 '15 at 13:14
  • I am deleting all the branches and starting over. I am really behind. And will be pulling RED BULL / MONSTER BOMBs all week and weekend, but I want I it to be right and I am a perfectionist. Not sure if that is a good or bad trait. – Moojjoo Jul 09 '15 at 13:16
  • I am going to add all the folders EXCEPT the FS (aka all images) when adding back to source control. I am writing this up because I want to help others if they run into this issue. – Moojjoo Jul 09 '15 at 13:17

2 Answers2

2

I would assume that .tfignore works the same with local and server workspaces, so:

Yes, you have to delete \FS from source control, but doing so from the Team Explorer should suffice. Add a .tfignore in \FSs parent directory. This will ensure that your \FS folder does not sit in source control and get copied over when you make a new branch.

Heki
  • 926
  • 2
  • 15
  • 34
  • @Moojjoo This is probably not very relevant to you anymore, but as you say yourself; to help others. – Heki Jan 13 '17 at 10:32
2

This is an old post, but I'm providing an answer anyway since I stumbled upon the same issue and finally found an answer:

Someone commented that .tfignore only works with local workspaces -> this is correct

The syntax for excluding entire subfolders within your current folder (where your .tfignore file resides) can be either of those:

  • /subfolder
  • \subfolder

If you want to exclude subfolders of subfolders or files in subfolders of it can be either of those or something similar (depending on what you want to filter out):

  • /subfolder/subsubfolder
  • \subfolder\subsubfolder
  • /subfolder/*.txt
  • \subfolder*.txt

It is noteworthy that tf.exe has some strange quirks, when anything isn't right nothing in .tfignore will have effect and you will not receive any visible error message (maybe hidden somewhere in some log, not sure). At first I thought I was having some issue with line endings, because when I added a new line with a new entry then nothing got excluded, only after adding a blank line in between. Later I noticed that it seems like tf.exe is doing some kind of validation that doesn't always succeed the first time for certain syntaxes. Hard to put my finger on under what scenarios exactly that happens, but it works the second time.

I suggest anyone doing this having the text editor open and save your changes in .tfignore, then check in Team Explorer if the detected files disappear (which they should if they're ignored). When this doesn't work within 1 to 3 seconds, try just saving the .tfignore file again without changing anything, then it'll probably work. I've seen this bevahior now 100 times.

After editing and saving .tfignore file:

enter image description here

After a blank re-save of the file:

enter image description here

openshac
  • 4,966
  • 5
  • 46
  • 77
DanDan
  • 1,038
  • 4
  • 15
  • 28
  • Thanks for the answer. I was facing problems in .Net projects using Angular as the frontend and directories like "dist" and "node_modules" being included in TFS even after I always deleted them before checking in. After adjusting the paths, including folders and subfolders ("\ClientApp\dist" and "\wwwroot\node_modules"), TFS no longer suggests such directories. – Silvair L. Soares Jan 29 '21 at 13:49