ionic gitignore file| Ignore files in git ionic example

In this blog post, We are going to learn the files not to commit for the ionic project. It includes a step-by-step ionic gitignore example.

ionic gitignore file example

.gitignore is a plain text file that contains files and folder paths ignored by git during the git commit command.

.gitignore is stored in the application’s root directory. You can, however, define it in any of your application’s subfolders.

Any editor, including vscode, sublime, atom, and plain text editors, can be used to modify or create this.

The gitignore file is used to maintain track of untracked files that can be skipped when committing to git. .gitignore is a simple text file that contains the path of files and folders of a current project.

gitignore files are created automatically during the creation of the ionic project with the Ionic CLI tool. However, You can still manually add the file if the application was created manually.

We will see the gitignore file for the ionic CLI project.

Let’s see what files do add to the .gitignore file in the ionic app.

  • Node_module dependencies folder, which is local to the project, and environment, not required to commit to the repository. bower_components for the bower package manager

  • Build package log files for npm and yarn as well as webpack

  • temporary folders like tmp


-  platform generated files for android and IOS using ionic command cli.

   This includes folders for android (/platforms/android) and IOS(platforms/ios)

- typing 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 the package-lock.json file
- bower\_components if the package manager used is a bower
-  .vscode folder ignore  for Visual Studio code editor

- .project and classpath files for the eclipse,
   .sublime-workspace files for Sublime text editor
  • environment secret keys
  • typescript generated files
  • grunt specific lock files

ionic gitignore file example

We have to add the following things to the gitignore file to ignore the files in the ionic project.

Here is a code for the ionic gitignore sample file example.

# See for more about ignoring files.

# compiled output

# dependencies
# IDEs, eclipse, and Editors

# IDE - VSCode

# miscellinous

# Generated System Files
# Platform for android files

# environment files

.gitignore for an Ionic project with an Android target

In Ionic projects, We have plugins and platforms to add to the gitignore file for Cordova plugins. platform/ios and platform/android folders are not committed to the git repository.

platforms / plugins / plugins / android.json;
plugins / ios.json;

if you are using a capacitor, There are some more entries to add



  • environment secret keys and confidential information will not commit to git, So don’t add these to the gitignore file
  • You can use any text editor to create and modify the file.
  • It does add to any folder of your project. A root project is a good way to apply the entire project
  • Ionic 3 and ionic 4 versions work with similar gitignore content.

Based on project needs, You can add/remove any directory or files in these files. You have to use the regular expression ** to ignore subdirectories inside a directory.