7

I code in MAC - OSX and my partner codes in PC - Windows but when I commit and push changes there are multiple files in project directories ending with .IML or .config or .properties, which gets overwritten and cause frequent overwrites which is a nuisance.

So my question is which files can be excluded from GIT for Android Studio Gradle Project to maintain the code in MAC as well as Windows? and what is the best way to do it ?

Gowrav
  • 189
  • 2
  • 17

1 Answers1

9

Here is a decent .gitignore file which you put in the root directory of your project, e.g. the folder where the .git folder is:

#built application files
*.apk
*.ap_

# files for the dex VM
*.dex

# Java class files
*.class

# generated files
bin/
gen/

# Local configuration file (sdk path, etc)
local.properties

# Windows thumbnail db
Thumbs.db

# OSX files
.DS_Store

# Eclipse project files
.classpath
.project

# Android Studio
*.iml
.idea/
#.idea/workspace.xml - remove # and delete .idea if it better suit your needs.
.gradle/
build/

app/build/

gradle/

#NDK
obj/

Then you execute the following commands to apply the .gitignore:

git rm -r --cached .
git add .
git commit -m "fixed untracked files"

See more here.

EDIT: I also recommend using the .gitignore plugin for Android Studio.

Community
  • 1
  • 1
azurh
  • 410
  • 4
  • 12
  • Will this remove the ignored files from the VCS, which were included in the previous commits ? – Gowrav Sep 20 '16 at 10:35
  • In short - yes. However, they will still be there, so you can access them from previous revisions. Further commits will omit the files specifies in .gitignore. – azurh Sep 20 '16 at 11:04