Tuesday, October 30, 2018

What not to commit for Angular 2|4|5|6|7 Project - Gitignore file example

In this blog post, We are going to learn the files not to commit for the angular project.

gitignore file for the angular project

Gitignore file is used to maintain untracked files which will be useful during git commit process to ignore the files.if each line added in gitignore file is to stop tracking the files during commit files. The angular project can be generated manually as well as angular CLI tool.
Angular project uses typescript. Typescript compiler or transpiled the components into javascript. During this stage, js and js.map files are generated. This can be ignore by adding it in gitignore file
We will see the gitignore file for angular cli project
gitignore file is created by default during angular project creation using cli tool

what not to commit for git in a angular cli project

  • Node_module dependencies folder that does not need to commit repository
  • Build package log files like npm and yarn as well as webpack
  • temporary folders like tmp
  • typings folder
  • Output folder of npm command execution like dist/output folder
  • output files of typescript compiler files
  • include mapping javascript files if any
  • environment specific files
  • exclude package-lock.json file
  • bower_components if package manager used is bower
  • Editor or IDE-specific files like the .vscode folder for Visual Studio code editor 
  • *.sublime-workspace files for Sublime text editor
  • .project and classpath files for eclipse
  • typescript generated files
  • grunt specific lock files

gitignore file example 

We have to add the following things to gitignore file to ignore the files
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
/tmp
/out-tsc

# dependencies
/node_modules

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings

# System Files
.DS_Store
Thumbs.db
Based on project needs, You can add any directory or files in this files. You have to use regular expression ** to ignore subdirectories inside a directory,

Related article


EmoticonEmoticon