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! ;)
As of Android Studio 0.8.4 .gitignore file is generated automatically when starting new project. By default it contains:
I agree with this statement, however I modify this file to change /build to build/ (This will include /build and /app/build) So I don't end up with all the files in app/build in my repository.
Note also that if you import a project from Eclipse, the .gitignore won't be copied, or "automagically" created for you.
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
To get a better idea, all you need are the following files
You could put everything else in the .gitignore file. All your app changes lies mostly in these files and folders. The rest you see in a basic project are gradle build files or Android Studio configuration files.
If you are using Android Studio, you can use "Import project" to successfully build the project. Alternatively you can build using command line, follow Building Android Projects with Gradle.
Tested with Android Studio 3.0
You might need to Install .ignore plugin.
You can auto-generate the .gitignore file for Android. Right click on folder and follow
Then Select Android from left panel and click Generate
Android Studio will generate .gitignore file which contains all the file need to ignore.
Taken from http://menukanows.com/how-to-add-gitignore-file-in-android-project/
As of Android Studio 0.8.4
.gitignore
file is generated automatically when starting new project. By default it contains: