Home » Android » Android studio – should the entire .idea directory be in git ignore?

Android studio – should the entire .idea directory be in git ignore?

Posted by: admin March 11, 2020 Leave a comment


I saw a lot of examples for .gitignore files for AndroidStudio, some have .idea in them, and some don’t.

Is there a good reason not to add the entire .idea dir to .gitignore?

If it should not be completely ignored, are there specific files inside .idea (such as .iml) that should be in .gitignore?

How to&Answers:

You can take a look at this page :

IntelliJ doc about project configuration files

In the “Directory-based format”, a particular line is interesting :

The .idea directory contains a set of configuration files (.xml). Each file contains only a portion of configuration data pertaining to a certain functional area which is reflected in the name of a file, for example, compiler.xml, encodings.xml, modules.xml.

Almost all of the files contain information core to the project itself, such as names and locations of its component modules, compiler settings, etc. Thus, these files may (and should) be kept under version control.

However, I properly HATE to make project IDE-dependent (I am currently working on a project made with NetBeans and it hurts to use it with Eclipse which becomes the standard of my company).

So, to answer your question :

  1. If you do not use something like Maven or Gradle to manage dependencies and build : keep the directory under version control. This way, the correct configuration of the project and dependencies will be available for everyone. In the counterpart, all developers will have to set their environment exactly the same way that you define it in the config files.
  2. If you do use something like Maven or Gradle : correctly configure these tools and do not keep the directory under version control. Actually, all the information contained inside config files should be stored in Maven/Gradle files. Then let your developers configure their IDE depending of their environment. This way, using Eclipse, IntelliJ, Linux, Windows … will not be a problem anymore.


OK, so after some “Yes” and “No” answers, I am adding a “Yes and no” answer 🙂

The problem is that .idea is used for both project build configuration (dependencies declaration) and project settings (inspections, etc.).

You definitely don’t want to use your IDE for your build configuration, but you might want to share the settings among the team. That’s why you need to ignore only a part of the .idea content (like the libraries folder and the modules.xml file), but keep others in the version control (e.g. the copyright, dictionaries and inspectionProfiles folders and files under .idea like dynamic.xml, codeStyleSettings.xml, etc.).


The concept of keeping the project configuration in VC is valid. I did this with my team because all of our developers happened to use PHPStorm for our projects and so it made sense to keep a common configuration … in concept. We wanted to use the same dictionary files, the same coding standard rules, and the same plugin configurations.

The reason why I qualify this with “in concept” is because there were issues with JetBrains’ .idea folder that led to us not being able to use it. These were probably issues that could have been avoided or fixed, but it was unclear to us how to do it right, and we think that’s a fault of JetBrains because as developers we do not have time nor desire to search for solutions on how to make our IDE work correctly.

That being said, the issues were had are the following:

  • Symlinking project folders doesn’t work right.
    When I set up my projects, I symlink them into my home directory. What we discovered was that the project was set-up to use the exact symlink rather than just treating it like a concrete directory. This means that if another developer keeps his project in a different place, or simply does not use symlinks, the entire directory will be missing from the project navigator because it is quite literally looking for the symlink. What’s worse is that I could never find this path value in the configuration. We were unable to find the exact config in the files constituting our .idea folder.
  • Definition files are partitioned to users by default. This means if I want to add a word to my dictionary, it will be listed as a definition for me, jgreathouse, but other users will have their own definition section. The flagged words will still show up as a spelling mistake for other users. This is not desireable. The reason I add it to my definition file is because the IDE is wrong. I want these definitions to be intuitively shared with other users.
  • Colleagues kept overwriting the configurations because their IDE would overwrite the configurations with their config currently in Memory. What I mean is that, a developer would be working, and merge their repository from origin, which would contain a project configuration change, instead of their IDE changing configurations, or even giving them a choice, it would automatically overwrite the .idea configuration with the current in-memory configuration of their IDE. In my opinion this makes the .idea configuration unusable as a shared configuration. In order to work around this, the developer would literally have to shut down that instance of their IDE, pull the repo, and re-open their IDE. It makes no sense to keep a shared configuration if the IDE instantly overwrites it with the configuration currently in memory. It’s like not having a shared configuration at all.

I’ve done these types of shared IDE configurations in VC before with Visual Studio and Netbeans and it was always fine; but with .idea it feels simply unusable which is disappointing. I wish JetBrains would get on top of it and make it a better user experience.