What's a good .gitignore for an ionic project?

Let’s say we’re building an app for ios, what would be a good .gitignore file? In other words, what should be ignored when committing a project to git?

This is undoubtedly related to phonegap/cordova, but since I’m not to both, any advice would greatly speed up my learning process.

Thanks for helping!

3 Likes

I would recommend the yeoman-ionic generator that comes with a default .gitignore

2 Likes

Thanks, would that be this .gitignore file? https://github.com/diegonetto/generator-ionic/blob/master/.gitignore

Actually, that is the .gitignore file for that repo.

would be what you are looking for.

Thanks for helping out. Does it make sense to ignore the www directory where most of the work takes place?

1 Like

Well taken out of context, no. If you are using a bare cordova project, you should not ignore that directory.

However, I highly recommend the yeoman generator. It does quite a bit for you out of the box.

Note that the www/index.html is a minified version of the app/index.html. This includes concatenating/minifying all of a particular app’s bower components that have been installed into one file, as well as your own files that you have added manually. It also does the same for your sass files – which is more advantageous that writing some custom css given the fact that ionic has some pretty sweet mixins that you can take advantage of.

The current way that I take advantage of the sass mixins is by importing the main ionic sass file into my own app.sass like so:

@import '../bower_components/ionic/scss/ionic'

This allows me to quickly extend the base styles that Ionic has already created with great ease. The only downside to this is, given the automated nature of the build process for this yeoman generator, the ionic css will be included twice when it builds/concatenates/minifies the sass file. Currently, the easiest way I have found to circumvent this is to remove any reference to a css file in the main array for the app/bower_components/ionic/bower.json and app/bower_components/ionic/.bower.json files respectively.

1 Like

I know I’m following up on this a little late, but any recommendations for a .gitignore for people not using yeoman yet. I’m just diving into ionic, working off of their starter app, etc, and trying to determine the best way to set up my .gitignore so that I’m not tracking a lot of unnecessary files.

2 Likes

A good starter is the .gitignore from the ionic-angular-cordova-seed project.

Note that platforms and plugins also have their own .gitignore.

I am using this:

node_modules/
platforms/
plugins/
resources/
www/lib

to ignore files which are generated by ionic/npm/bower.

2 Likes

I have used the below, considering the iOS and Android build ignores too:

Specifies intentionally untracked files to ignore when using Git

http://git-scm.com/docs/gitignore

Common Ignores

.vscode/
.DS_Store

ionic

node_modules/
plugins/

Platform iOS

*.mode1v3
*.perspectivev3
*.pbxuser
platforms/ios/build

Platform Android

platforms/android/build.xml
platforms/android/local.properties
platforms/android/gradlew
platforms/android/gradlew.bat
platforms/android/gradle

Ant builds

platforms/android/ant-build
platforms/android/ant-gen

Eclipse builds

platforms/android/gen
platforms/android/out

Gradle builds

platforms/android/build

1 Like

Should we ignore this as well?

resources/
config.xml