How to deal with IntelliJ IDEA project files under Git source control constantly changing?

You can use IDEA's directory-based project structure, where the settings are stored in .idea directory instead of .ipr file. It gives more fine-grained control over what is stored in version control. The .iml files will still be around, so it doesn't solve the random changes in them (maybe keep them out of source control?), but sharing things such as code style and inspection profiles is easy, since each of them will be in its own file under the .idea directory.


From official DOC: http://devnet.jetbrains.com/docs/DOC-1186

Depending on the IntelliJ IDEA project format (.ipr file based or .idea directory based), you should put the following IntelliJ IDEA project files under the version control:

.ipr file based format

Share the project .ipr file and and all the .iml module files, don't share the .iws file as it stores user specific settings.

.idea directory based format

Share all the files under .idea directory in the project root except the workspace.xml and tasks.xml files which store user specific settings, also share all the .iml module files.

I put it in my .gitignore:

#Project
workspace.xml
tasks.xml

An official answer is available. Assuming you're using the modern (and now default) .idea folder project format:

  • Add everything...
  • Except .idea/workspace.xml (which is user-specific)
  • Except .idea/tasks.xml (which is user-specific)
  • Except some other files that might contain passwords/keys/etc (see above link for details)

This sample .gitignore file might be a useful reference, though you should still read the above link to understand why these entries appear and decide if you need them.

Personally I also ignore the .idea/find.xml file as this seems to change every time you perform a search operation.