Search code examples
gitcordovacordova-3

.gitignore for PhoneGap/Cordova 3.0 projects - what should I commit?


I just tried to create a new phonegap 3.0 project... Note: I'm new to phonegap. Anyways, I see the project folder contains:

  • .cordova
  • merges
  • platforms
  • plugins
  • www

And having tried phonegap local run android I see a lot of binary/generated files in platforms/android. This leaves me wondering, what parts of this folder structure should I add to my git repository. Normally, I would consider it extremely poor practice to commit binary files. Hence, I would normally add patterns like bin/, obj/, *.o, *.pyc etc. to .gitignore to avoid polluting my git repository with things that only serves to create merge conflicts.

Surely, www should be added to git, but what about the other parts of the project. To what extend are they products of the source code, and to what extend are they project configuration?

What do you do? Granted I'm new so I barely understand what makes sense here...


Solution

  • The answer depends on wich platforms you're developing the phongap app, and if you're following the standard directory structure.

    If your project directory structure is standard, then you can start from this gitignore and modify it for your needs.

    On a rule of thumb you've to exclude all generated files like the bin/ and gen/ directories. If you're developing an Android version of your app you should exclude build files too like *.apk.

    All generated files in the android subdirectory should be excluded too:

    Android/bin/
    Android/gen/
    Android/assets/