{

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 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 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 project, environment, not required to commit to repository. bower_components for the bower package manager

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

      *.DS_Store
      *.log
      *.swp
      *.swo
      *.log
    
  • temporary folders like tmp

  /tmp
  .temp
  /temp

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

   This includes folders for android (/platforms/android) and IOS(platforms/ios)
   ```markup
   platforms/
   platforms/android/
   platforms/ios/build
   plugins/
   resources/
   www/lib
   .mode1v3
   *.perspectivev3
   *.pbxuser
   ```


- typing's folder
   ```markup
   /typing/
   ```
- Output folder of npm command execution like dist/output folder
 ```markup
   /dist/
   /build/
   /output/
   ```

- 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 a bower
-  .vscode folder ignore  for Visual Studio code editor 
   ```markup
   .vscode
   ```

- .project and class path files for eclipse,
   .sublime-workspace files for Sublime text editor
```markup
   .idea
   *.sublime-project
   *.sublime-workspace
   .DS_Store
   Thumbs.db
  • environment secret keys
 .env
  • 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 ionic gitignore sample file example.

# See http://help.github.com/ignore-files/ for more about ignoring files.  
  
# compiled output  
/dist  
/tmp
/temp
/out-tsc  
  
# dependencies  
/node_modules  
/bower_components
# IDEs, eclipse and Editors  
/.idea  
.project  
.classpath  
.c9/  
*.launch  
.settings/  
*.sublime-project
*.sublime-workspace
npm-debug.log*
.ionic/
.sourcemaps/
.sass-cache/


  
# IDE - VSCode  
.vscode/*  
!.vscode/settings.json  
!.vscode/tasks.json  
!.vscode/launch.json  
!.vscode/extensions.json  
  
# miscellinous
/.sass-cache  
/connect.lock  
/coverage  
/libpeerconnection.log  
npm-debug.log  
yarn-error.log  
testem.log  
/typings  
  
# Generated System Files  
.DS_Store  
Thumbs.db  
# Platform for android files
platforms/
platforms/android/
platforms/ios/build
plugins/
resources/
www/lib

# environment files
.env
.env-prod

.gitignore for an Ionic project with 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

contents.xcworkspacedata
android-template/.gradle/
android-template/app/app.iml
android-template.iml

Notes

  • 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. Root project is a good way to apply to 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 regular expression ** to ignore subdirectories inside a directory.

THE BEST NEWSLETTER ANYWHERE
Join 6,000 subscribers and get a daily digest of full stack tutorials delivered to your inbox directly.No spam ever. Unsubscribe any time.

Similar Posts
Subscribe
You'll get a notification every time a post gets published here.