Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to exclude typescript compiled files from git

I have a visual studio solution with a few asp.net 5 project. Inside every project I have a wwwroot directory and inside this an app directory that contains the html views, .js and .map files that are typescript files compiled in this position.
With the standard configuration these files are included in the checkin. How can configure the .gitignore file so all the .js and .map files, inside every subdir of the wwwroot\app directory of every project in the solution are ignored?

like image 839
Luca Morelli Avatar asked Nov 27 '15 13:11

Luca Morelli


People also ask

How do I exclude files from a Git repository?

Open the . git/info/exclude file in a text editor and add the folder to ignore. This file remains private to you.

How do Gitignore files work?

A . gitignore file is a plain text file where each line contains a pattern for files/directories to ignore. Generally, this is placed in the root folder of the repository, and that's what I recommend. However, you can put it in any folder in the repository and you can also have multiple .

What is Gitignore template?

gitignore file is a text file that tells Git which files or folders to ignore in a project. A local . gitignore file is usually placed in the root directory of a project. You can also create a global . gitignore file and any entries in that file will be ignored in all of your Git repositories.


2 Answers

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

The ** will match everything inside app, also multiple levels of subdirectories.

like image 122
crea1 Avatar answered Sep 24 '22 13:09

crea1


Add the following lines to your .gitignore:

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

You can read more about gitignore and supported patterns here.

** matches subdirectories recursively. The first one is there for the projects, the second one is there because you mentioned

inside every subdir of the wwwroot\app directory

like image 31
Sergio Avatar answered Sep 25 '22 13:09

Sergio