Val Okafor Val Okafor - 1 month ago 10
Git Question

Where Exactly Should I Place .GitIgnore File in Android Studio Project

I have placed the following .gitignore file at the root of my Android Studio Project

# Built application files
*.apk
*.ap_

# Files for the Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/

# Gradle files
.gradle/
build/

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

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Windows clutter
Thumbs.db

# Intellij IDEA (see https://intellij-support.jetbrains.com/entries/23393067)
.idea/workspace.xml
.idea/tasks.xml
.idea/datasources.xml
.idea/dataSources.ids


However the following .gradle contents keeps getting added to the source control.

modified: .gradle/1.12/taskArtifacts/cache.properties.lock
modified: .gradle/1.12/taskArtifacts/fileHashes.bin
modified: .gradle/1.12/taskArtifacts/fileSnapshots.bin
modified: .gradle/1.12/taskArtifacts/taskArtifacts.bin


.gradle and its sub folders are marked to be ignored in the .gitignore however these keeps getting updated each time I so much as run the app in an Emulator. I do not remember dealing with these in Eclipse projects.

Are these .gradle files I showed above necessary to be version controlled, if not how can I modify my .gitignore to actually ignore them?

Answer

If the .gradle files are already in the git repository you need to clean them up first using git rm -rf gradle/. Don't forget to commit your changes after using git rm.