What files should be in my .gitignore
for an Android Studio project?
I've seen several examples that all include .iml
but IntelliJ docs say that .iml
must be included in your source control.
What files should be in my .gitignore
for an Android Studio project?
I've seen several examples that all include .iml
but IntelliJ docs say that .iml
must be included in your source control.
I know this is an old topic and there are certainly a lot of options, but I really prefer
gibo
by Simon Whitaker. It's super simple to use, cross-platform (mac, *nix, and windows), and uses the githubgitignore
repo so it is (basically) always up to date.Make sure your local cache is up to date:
Search for the language/technology you need:
Display the .gitignore file:
Now, append it to your project's .gitignore file:
(Make sure you use
>>
to append to your project's .gitignore file; one>
will overwrite it - as I've done many times on accident!)I know this isn't answering the OP's exact question, but using gibo makes it so you pretty much don't have to think about 'the question' anymore! .. it's nice! ;)
To circumvent the import of all files, where Android Studio ignores the "Ignored Files" list, but still leverage Android Studio VCS, I did the following: This will use the "Ignored Files" list from Android Studio (after import! not during) AND avoid having to use the cumbersome way Tortoise SVN sets the svn:ignore list.
Going forward, "Ignored Files" will be ignored and you can still manage VCS from Android Studio.
Cheers, -Joost
This official documentation from JetBrains Support says the following should be included:
It also gives other recommendations of things to be careful about.
There is NO NEED to add to the source control any of the following:
So you can configure hgignore or gitignore accordingly.
The first time a developer clones the source control can go:
That's all
PS: Android Studio will then, through maven, get the gradle plugin assuming that your build.gradle looks similar to this:
Android studio will generate the content of .idea folder (including the workspace.xml, which shouldn't be in source control because it is generated) and the .gradle folder.
This approach is Eclipse-friendly in the way that the source control does not really know anything about Android Studio. Android Studio just needs the build.gradle to import a project and generate the rest.
Depends on how your project format is maintained:
You have two options:
.idea
folder which contains the project specific files).iws
and.ipr
)Ref: http://www.jetbrains.com/idea/webhelp/project.html
Files committed to version control depends on the above:
workspace.xml
andtasks.xml
.ipr
file and all the.iml
module files, exclude the.iws
file as it stores user specific settings.Ref: https://intellij-support.jetbrains.com/entries/23393067
Updated to Android Studio 3.0 Please share missing items in comments.
A late answer but none of the answers here and here was right on the money for us...
So, here's our gitignore file:
Since Android Studio 2.2 and up to 3.0, new projects are created with this gitignore file:
Deprecated - for older project format, add this section to your gitignore file:
This file should be located in the project's root folder and not inside the project's module folder.
Edit Notes:
Since version 0.3+ it seems you can commit and push *.iml and build.gradle files. If your project is based on Gradle: in the new open/import dialog, you should check the
"use auto import"
checkbox and mark the"use default gradle wrapper (recommended)"
radio button. All paths are now relative as @George suggested.Updated answer according to @128KB attached source and @Skela suggestions