如何从 git 中排除打字稿编译文件

how to exclude typescript compiled files from git

我有一个 visual studio 解决方案,其中包含几个 asp.net 5 个项目。在每个项目中,我都有一个 wwwroot 目录,在这个目录中有一个 app 目录,其中包含 html 视图、.js 和 .map 文件这是在这个位置编译的打字稿文件。
使用标准配置,这些文件包含在签入中。如何配置 .gitignore 文件,以便所有 .js 和 .map 文件,在每个 wwwroot\app 目录的每个子目录中解决方案中的项目被忽略了?

wwwroot/app/**/*.js
wwwroot/app/**/*.map

** 将匹配 app 中的所有内容,也匹配多级子目录。

将以下行添加到您的 .gitignore:

# Ignores compiled TypeScript files
**/wwwroot/app/**/*.map
**/wwwroot/app/**/*.js

您可以阅读更多关于 gitignore 和支持的模式 here

** 递归匹配子目录。第一个是针对项目的,第二个是因为你提到了

inside every subdir of the wwwroot\app directory