Angular .gitignore template
The Angular template ignores compiled output, intermediate type checker output and the local build cache, alongside logs from the older test and end to end tooling.
At a glance
- Category
- Framework
- Patterns in this template
- 17 rules
- Directories ignored
- 8 of the 17 rules end in a slash, so they match directories only
- Also needs an OS template
- Yes. Nothing here matches file manager artefacts.
- Typical companions
- npm, Yarn or pnpm, plus an OS template and an editor template.
In detail
dist is the production output and out-tsc is the intermediate directory the type checker writes into during a build. Keeping them separate is a detail of how the toolchain runs the compiler twice, once for type checking and once for bundling, and both directories are pure output.
.angular/cache is the local build cache. It stores compiled module output keyed to content hashes so a rebuild only redoes what changed. Like every build cache it is specific to the machine, the toolchain version and the dependency set, and a copy from someone else's machine is at best ignored and at worst a source of confusing stale output.
The e2e/*.js and e2e/*.map rules cover compiled end to end test files, which exist because those tests are written in TypeScript and compiled before running. testem.log, connect.lock and libpeerconnection.log come from the older browser test runner and the browser it launched, and they turn up in the project root during a test run.
bazel-out is the output directory for projects built with the alternative build system. .sass-cache is the compiled stylesheet cache from an older preprocessor setup, and typings is the pre modules directory for third party type declarations. Several of these are historical, kept because they cost nothing and an older repository may still produce them.
.env is included, which is a slightly unusual choice for a browser framework. Values that reach the browser bundle are readable by anyone who loads the page, so the rule is protecting a build time value or a local server configuration rather than anything that stays secret at runtime.
Examples
dist/
tmp/
out-tsc/
bazel-out/
node_modules/
e2e/*.js
e2e/*.map
.angular/cache
*.launch
.settings/
*.sublime-workspace
.sass-cache/
connect.lock
libpeerconnection.log
testem.log
typings/
.env17 lines exactly as the tool writes them, before any common additions you tick.
Things that catch people out
- *.launch and .settings/ are Eclipse artefacts carried into this template. They do not cover the editor most Angular teams use, so add a template for yours.
- .angular/cache can grow to hundreds of megabytes. Ignoring it is right, but it is also worth clearing occasionally rather than only when disk space runs out.
- tmp/ is unanchored, so a fixture directory named tmp anywhere in the project is ignored along with the build temp directory this rule targets.
Try it: .gitignore Generator
Pick one or more templates, tick the common additions you want, and copy or download the combined .gitignore.
.gitignore Generator
LOCAL · Browser-OnlyGenerate comprehensive .gitignore files by combining templates for languages, frameworks, IDEs, and operating systems
Language
Framework
IDE
OS
Build Tool
Infrastructure
Common Additions
Preview
Select templates or common additions to generate a .gitignore file.
Related .gitignore templates
All .gitignore templates →TypeScript .gitignore template
The TypeScript template ignores compiled output, source maps and build info, but its *.d.ts rule is broader than most projects want. Here is each line.
React .gitignore template
A short template built around one idea: the .env.local family is per developer and never committed, while the plain .env is shared and usually should be.
Node.js .gitignore template
The longest JavaScript oriented template: dependency directories, every package manager's debug log, bundler caches, env files and Yarn Plug'n'Play state.
Django .gitignore template
The Django template adds four framework rules to the usual Python ones: local settings, the SQLite database, uploaded media and collected static files.
Flask .gitignore template
The Flask template adds the instance folder to the usual Python rules, which is the framework's designated place for configuration that must not be committed.
Rails .gitignore template
The Rails template is built around the encrypted credentials system: the encrypted file is committed, the key that decrypts it never is. Every rule explained.
Tools for this
- .gitignore Generator Generate .gitignore files for any project - 50+ templates for languages, frameworks, IDEs, and OS