Exclude a folder from checkin TFS online

2019-04-14 10:57发布

问题:

i am using visualstudio.com as TFS online and have created my code repo there.

In my project there is folder that comprises several subfolders and eachsub folder has several images (the total of all images is like 6000).

When i check-in my code I do not want the root folder (i.e. the parent folder of image subfolders) and its content to be checkedin?

I tried online for some answers but cannot find anything accurate.

Thanks in advance for your help.

回答1:

You can configure which kinds of files are ignored by placing text file called .tfignore in the folder where you want rules to apply. The effects of the .tfignore file are recursive. However, you can create .tfignore files in sub-folders to override the effects of a .tfignore file in a parent folder.

To create the file, the easiest way is using the auto automatically generated .tfignore file, follow below steps:

  1. In the Pending Changes page, in the Excluded Changes section, choose the Detected changes link.

The Promote Candidate Changes dialog box appears.

  1. Select a file, open its context menu, and choose Ignore this local item, Ignore by extension, Ignore by file name, or Ignore by folder.

  1. Choose OK or Cancel to close the Promote Candidate Changes dialog box.
  2. A .tfignore file appears in the Included Changes section of the Pending Changes page. You can open this file and modify it to meet your needs.

More info please check the Customize which files are ignored by version control from MSDN Link:Add files to the server



回答2:

Method 1:

There's an easy way to do it, i.e. via the .tfignore file. Go to the root folder of your and tfs checkin and put following content in the .tfignore file. If the file is not there create it.

.tfignore

<rootfoldername>

Method 2:

To exclude a file from source control

  1. In Visual Studio, open Solution Explorer and select the file to exclude.
  2. On the File menu, click Source Control, then click Exclude from Source Control.
  3. When you are ready to place the file under source control, you can access the File menu and click Source Control, then uncheck Exclude from Source Control.

Edit: This question is a possible duplicate of How to ignore files/directories in TFS for avoiding them to go to central source repository?

Edit: Changed the file name to .tfignore