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 managernode_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)
```typescript
platforms/
platforms/android/
platforms/ios/build
plugins/
resources/
www/lib
.mode1v3
*.perspectivev3
*.pbxuser
```
- typing folder
```typescript
/typing/
```
- Output folder of npm command execution like dist/output folder
```typescript
/dist/
/build/
/output/
```
- 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
```typescript
.vscode
```
- .project and classpath files for the eclipse,
.sublime-workspace files for Sublime text editor
```typescript
.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 the 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 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
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. 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.