At one point I was coding on a hobby project, using Visual Studio Online for project management and source control. Because of the technologies involved, a large number of temporary files were being generated that I didn’t want checked in. Visual Studio’s TFS integration is pretty good at automatically filtering these kinds of files out and placing them in the Excluded Changes list in the Pending Changes window, but in my case the sheer number made it a pain to scan the Excluded Changes list for valid changes that I actually wanted to commit.

In my case, I didn’t want those temporary files to show up at all – not even in the Excluded Changes list. In order to gain control over which files TFS should ignore completely, I added .tfignore files to my solution. These allow you to specify which files, extensions and directories to ignore (or un-ignore!) from source control. If you’re familiar with the concept of .gitignore files in GIT, you should feel right at home.

Example excluded changes view before adding tfignore rules.

You can either manually create a .tfignore file in your solution, or you can add one automatically in Visual Studio by clicking the “Detected” link and then right-clicking on the files under the Excluded Changes list and selecting one of the Ignore options:

Creating a tfignore file using the IDE.

Once you select one of the ignore options, a .tfignore file will automatically be added to the root of our solution as a result:

A tfignore file in an example solution.

In this case, I chose “ignore by extension”, so this file contains a rule specifying that version control should ignore all files with the .txt extension. This rule will apply to the directory containing the .tfignore file and all subdirectories. The syntax of the rule is simple:

# This rule ignores files with the .txt extension
*.txt

The comment block at the top of the auto-generated .tfignore file provides example syntax for this and other usages such as limiting rules only to the local directory, limiting rules to a specific named directory, excluding an entire directory, and more.

# ################################################################################
# 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
#
################################################################################

It is important to pay close attention to the scoping of .tfignore rules in order to avoid excluding files unintentionally, as these rules apply recursively to the local directory and all subfolders unless explicitly stated otherwise. In that regard, the final rule in the comment block above is notable in that it allows a .tfignore file in a child directory to override a rule specified by a .tfignore file in a parent directory.

Returning to my earlier example, if I were to add a Documents directory to my solution containing an IncludeMe.txt file, TFS would ignore the text file based on my initial rule. However, I can add a second .tfignore file to the Documents directory with the rule “!*.txt” to override the higher-level .tfignore rule and allow version control to detect IncludeMe.txt:

IncludeMe.txt is detected based on the higher-level override rule.

IncludeMe.txt now appears under the Excluded Changes list in the Detected link, allowing me to promote it and include it in source control.

Excluding Files From Team Foundation Version Control Using .tfignore Files相关推荐

  1. TFS文件编码检查机制和修改(Team Foundation Server 2013)

    TFS的版本控制系统会自动按照下面的标准检测代码文件的编码格式: 1. 首先,如果代码文件包含了BOM部分,则使用BOM中制定的编码格式打开文档 什么是BOM (Byte order mark)? h ...

  2. 【原创】Team Foundation Server 域环境迁移

    先说下此片博客的上下文:部门所在的业务被集团出售,因此我们所有的计算机和服务器都得重新命名,退出当前域加入新公司的域.对于PC和其他服务器,目前不存在太大问题.但是对于Team Foundation ...

  3. Team Foundation Server的回滚操作

    VSTF Rollback 操作 最近遇到要把有些项目需要做回滚操作,发现TFS的UI上没有回滚的操作. 经过百度,查到一个CSDN上的博主发了一种方法,经过验证,那种方法是错误的: 他通过先获取指定 ...

  4. Team Foundation Server Beta3 安装指南

    Team Foundation Server Beta3 安装指南 发布日期: 11/11/2005 | 更新日期: 12/15/2005 本页内容 1.概述 2.安装的安全 3.单服务器的安装过程 ...

  5. 谈谈Team Foundation Server Proxy

    好久没来这里更新了,锄锄草 :) Team Foundation Server的配置管理是可以远程访问的,对于有异地开发的团队来说,这一点非常重要!并且,还不仅仅只是能够访问,这里还有一个重要的组件T ...

  6. Team Foundation Server安装指南(转)

    1.说明 Team Foundation Server(以下简称VSTF)的安装并不是一件轻松的事情,在安装的过程中相信很多人都或多或少碰到一些问题而安装不成功,虽然手头有微软提供的所谓安装手册,也曾 ...

  7. 让Visual Studio 2005 Team Foundation Server支持Wss3

    公司的TFS2005开发了若干基于moss2007的产品.由于TFS2005是基于Wss2.0的,导致在使用builder时有些项目编译不过,可能是需要调用Wss3.0的东西吧.而一些第三方的插件都是 ...

  8. version control(版本控制)

    版本控制系统(version control system),是一种记录一个或若干文件内容变化,以便将来查阅特定版本修订情况的系统.版本控制系统不仅可以应用于软件源代码的文本文件,而且可以对任何类型的 ...

  9. Team Foundation Server安装指南

    1.说明 Team Foundation Server(以下简称VSTF)的安装并不是一件轻松的事情,在安装的过程中相信很多人都或多或少碰到一些问题而安装不成功,虽然手头有微软提供的所谓安装手册,也曾 ...

最新文章

  1. python自动测试p-关于《Python自动化测试实战》
  2. redis高级-内存淘汰策略
  3. C# NTP时间同步类
  4. wordpress 自定义分类url 重写_WordPress导航主题-WebStack导航主题
  5. clipse中Access restriction: The type ‘XXX’ is not API 解决
  6. PHP伪协议-文件包含漏洞常用的伪协议
  7. 微服务之间的调用方式RestTemplate和FeignClient
  8. Windows timeout命令
  9. Oracle system表空间用满解决
  10. 「cocos2d-x」垂直射击游戏之宇智波鼬 VS 九尾狐(1)
  11. JSP打印九九乘法表和表格
  12. 天图投资冲刺港股:资产管理规模249亿 投了小红书与奈雪
  13. 总体和个体,样本和样本值
  14. Progressive Layered Extraction: A Novel Multi-TaskLearning Model for Personalized Recommendations
  15. 双11技术总指挥汤兴:今年双11是技术和商业的完美共振
  16. Esp32 TCA9555 基于Arduino基于 microByte
  17. 数据挖掘与数据分析项目链家租房数据(三)进一步探索与归纳
  18. 地图热区随屏幕大小改变
  19. php保留小数点4位,PHP小数点后保留几位的教程实例
  20. 台达-canopen操作

热门文章

  1. js中同名的函数的调用情况
  2. android 面试汇总二
  3. Linux空硬盘从分区到挂载
  4. maven2-snapshot快照库和release发布库的应用
  5. LPC1768的SPI通讯
  6. oracle中DECODE与CASE的用法区别
  7. Fiddler的钩子hook导致电脑无法连上网络
  8. [Kali][VMware][2020][窗口大小][分辨率]高分辨率自适应
  9. 微机计算机原理姚向华课后答案,微型计算机操作系统
  10. cad怎么把图层英文变成中文_CAD图层管理器昨天是中文的今天怎么变英文 – 手机爱问...