How to manage projects under Version Control Systems

To share IDE project files with other developers, follow the guidelines below.

Default project format (.idea directory)

Directory-based. The default format used across all present-day versions of Intellij-based IDEs.

What needs to be shared:

  1. All files under the .idea directory in the project root except the items that store user-specific settings:
    • workspace.xml
    • usage.statistics.xml
    • shelf directory
  2. All the .iml module files (can be located in different module directories) -> applies to IntelliJ IDEA

Note that starting with version 2019.1, IntelliJ is capable of adding everything that needs sharing to Version Control automatically.

 

Items you need to be cautious about:

  • Android artifacts that produce a signed build (will contain keystore passwords)
  • In IDEA 13 and earlier, the dataSources.ids and datasources.xml files can contain database passwords. IDEA 14 solves this problem.

Items you may want to exclude from sharing:

  • .iml files and .idea/modules.xml file for the Gradle or Maven based projects since these files will be generated on import
  • gradle.xml file, see this discussion
  • user dictionaries folder (to avoid conflicts if other developer has the same name)
  • XML files under .idea/libraries in case they are generated from Gradle or Maven project

Legacy project format (.ipr/.iml/.iws files)

File-based. Outdated and not recommended for use.

  • Share the project's .ipr file and all the .iml module files.
  • Do not share the .iws file as it stores user specific settings.

 

For Git, you can use this .gitignore as the starting point.

270 out of 365 found this helpful
123 comments

Timothyfroehlich No, your changes to the project structure will be discarded on the next project re-import/refresh.

To add additional source roots via Gradle, see https://stackoverflow.com/questions/28345705/how-can-i-add-a-generated-source-folder-to-my-source-path-in-gradle .

0

Serge Baranov You're right. I just needed to close down Android Studio for the change to be written to the .idea files. I'll have to figure out why the directory won't show up as source despite having added to Gradle. I've probably got a typo somewhere.

0

CLion 2024.2 creates a ".name" file in the .idea directory. This file is not ignored by CLion's default .gitignore for the .idea directory. However, the content of the ".name" file is just the directory name of the project root, which is clearly user-dependent and thus should not be shared. 

Furthermore, I'm seeing the editor.xml file changed quite frequently for things like 

<option name="/Default/Environment/Hierarchy/GeneratedFilesCacheKey/Timestamp/@EntryValue" value="137" type="long" />

with value changes from 133 to 137 or something like that. This also doesn't seem very useful to be shared?

Generally, I'm not sure if this concept of ignoring user-specific settings and unimportant cache data works out if that isn't reflected in the actual IDEs.

Edited by Rumms
0

Please sign in to leave a comment.

Have more questions?

Submit a request