1

I am developing an app using Android-Studio. To version-control my code, I am using GitLab. So, I've created the following .gitignore file to avoid committing everything:

# built application files
*.apk
*.ap_

# files for the dex VM
*.dex

# Java class files
*.class

# built native files (uncomment if you build your own)
# *.o
# *.so

# generated files
bin/
gen/

# Ignore gradle files
.gradle/
build/

# Crashlytics configuations
com_crashlytics_export_strings.xml

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

# Proguard folder generated by Eclipse
proguard/

# Signing files
.signing/

# Eclipse Metadata
.metadata/

# Mac OS X clutter
*.DS_Store

# Windows clutter
Thumbs.db

# Intellij IDEA (see https://intellij-support.jetbrains.com/entries/23393067)
.idea/workspace.xml
.idea/libraries/
.idea/tasks.xml
.idea/.name
.idea/compiler.xml
.idea/copyright/profiles_settings.xml
.idea/encodings.xml
.idea/misc.xml
.idea/modules.xml
.idea/scopes/scope_settings.xml
.idea/vcs.xml
.idea/datasources.xml
.idea/dataSources.ids
*.iml

build/intermediates/dex-cache/cache.xml

.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

However, whenever I try to commit-changes, the commit includes the build folder and .iml file (highlighted in the attached image), even though they are stated in the .gitignore file.

How to make Android-studio ignore these files and folders ?!

McLan
  • 2,552
  • 9
  • 51
  • 85

2 Answers2

0

To get Intellij IDEA (and by extension, Android Studio) to completely ignore files and folders use the following in Editor -> File Types -> Ignore Files and Folders:

enter image description here

From https://www.jetbrains.com/help/idea/2016.2/file-types.html:

Ignore files and folders : In this text box, specify the files and folders, which you want to be ignored by IntelliJ IDEA. Such files and folders will be completely excluded from any kind of processing. By default the list includes temporary files, service files related to version control systems, etc.

Ashutosh Jindal
  • 18,501
  • 4
  • 62
  • 91
0

Try This one

First commit any outstanding code changes, and then, run this command:

git rm -r --cached .

This removes any changed files from the index(staging area), then just run:

git add .

Commit it:

git commit -m ".gitignore is now working"

Complete Answer here

Community
  • 1
  • 1
RAJESH KUMAR ARUMUGAM
  • 1,560
  • 21
  • 35