Select Page


IntelliJ IDEA is a good choice for beginners as an Integrated Development Environment, developed by JetBrains, targeting JVM programming languages. One of its cool features is the addition of the .idea folder. This folder is automatically created by the IDE if you’re working on a git repository. Inside the folder, there are project-specific configuration files in .xml format, which are used by the IDE itself, to differentiate settings used in different projects. These include the core information of your project, compiler settings, names of the modules among many others. 

However, there might be times when you wish to ignore committing the .idea folder in your git repository, or any specific files under that folder. If you’re unsure whether to ignore committing this folder or not by adding it in the .gitignore file, this article will guide what to consider doing.

Should I ignore the .idea directory for Intellij IDEA?

It’s probably a good idea to ignore it, but there sure are exceptions. The developers behind JetBrains deems it mandatory to keep the .idea folder as is in your repository beforehand, so that all your configuration settings for the project can be shipped to the users as well. This folder will probably not be of any bother if your users aren’t supposed to start the project with Intellij IDEA. If your project is mostly a source code and all it involves is compilation for use as a program, then it doesn’t really matter if you leave the .idea folder as is or ignore it. However, this might not well be the only scenario.

Oftentimes when working in collaboration with a team of developers, this choice is not so independent. If all the members are required to use the same configuration, you’d probably want to keep the .idea folder. But if it is that every other person needs their very own configuration for the editor to match their own specific workflow, then you should definitely ignore the .idea folder as it could disrupt their configurations in that manner. So you should keep your situation in mind before you decide to ignore it using the .gitignore file. 

In the next section, we’ll discuss the different ways you can ignore the .idea folder.

How to ignore .idea directory using .gitignore

Using the project’s .gitignore file

Inside the .idea folder, different types of settings are stored in different .xml files. So if you wish to ignore only parts of the .dea folder, then you may simply do so by specifying those files in .gitignore instead of the entire .idea folder. But before all, the following line is what you’d like to add up in the .gitignore file found under the root directory of your project, to ignore the entire idea folder:


The forward slash at the end is required to ignore all the files under the .idea folder. 

Now in case you want to ignore only certain files under the .dea folder, for example, a common one called workspace.xml, simply add its name in the .gitignore file like this:


As simple as that! If there are more, simply 

add them up, with one file on each line:


Using the global .gitignore file

If you want the .gitignore files in all the projects present in your system to ignore the .idea folder, by following the root directory method, you’ll have to append those lines in all the files separately. Also, if more projects are on the queue, you can probably already imagine the trouble you need to go through. Worry not, as there’s an easier shortcut. That is, to create a global .gitignore file in your system which will be linked to all the .gitignore files present under any git repository.

To do this, open the file called .gitconfig (which should be located in your home directory) by using a text editor like nano:

$ nano ~/.gitconfig

Inside this file, append the following lines:

   excludesfile = ~/.gitignore

Save and exit the file. We’re done with this one. Now create a global .gitignore file in your home directory:

$ touch ~/.gitignore

Lastly, open this new file and then include:

$ nano ~/.gitignore

and then include the .idea folder inside this file by appending:


This file will be responsible for globally ignoring the .idea folders around your entire system. So you won’t need to go to every repository’s gitignore file to append it!

Using .git/info/exclude

The exclude file found under the .git/info sub-folder of a git repository works similarly like the project’s gitignore file, just with lower precedence. You can also use this file similarly like the .gitignore file by appending .idea as previously shown:



This concludes our walkthrough of ignoring the .idea folder for a git repository. Make sure to keep in mind not to ignore it if it is required by your team, or the users themselves. Having settings specific to a project for the Intellij IDEA means that your users will not have to go through the hassle of setting their workspaces up. However, not every other user might benefit from that, so it could actually be a good idea to ignore it.