skip to Main Content

In our project there is .idea folder checked-in into git repository with old content
(there is even .iml file that is actually previous generation),
and it puts project into dirty state right after import.

While ultimate solution will be to remove .idea folder completely,
is there a way to configure alternative location for IDE .idea folder,
so that when I work on the project current .idea folder is not used and not modified.

.idea content

2

Answers


  1. ‘No’. The .idea folder is specific to Jetbrains IDEA applications (Intellij, Webstorm, etc..) and is used to configure your IDE per your workstation environment or shared developer settings.

    That being said, you do have options:

    • If you’re the only person on your team using Jetbrains tools, you can safely add the folder to your .gitignore file. That will stop git (and IDEA) from monitoring or caring about changes.
    • Jetbrains has guidance on what each file is for and which ones you might consider checking in to your VCS and they have a default .gitignore you can use here
    • You could also setup a symlink to a different directory if you really wanted to. However, that comes with some risks in terms of backing up files and I think git will still see those file changes. You would definitely want to add .idea to your .gitignore then, as other developers won’t have the same folder structure and the symlink will ‘break’ for them.
    Login or Signup to reply.
  2. is there a way to configure alternative location for IDE .idea folder, so that when I work on the project current .idea folder is not used and not modified?

    Yes, you can keep your .idea elsewhere.

    Please note:

    • I will be using PhpStorm as an IDE (JetBrains IDE I’m using). It has simple project config (where the project consists of a single module of WEB_MODULE type; the same applies to WebStorm) while Java/Python/Ruby one have more complicated project settings (where it’s normal (especially for Java world) to have multiple modules per project).

    • I’m not sure how easy it is to change this for existing project (it’s not a problem for a new project). Might be possible to do manually by editing the config files directly, but cannot guarantee that it will not have some side effects (especially if it’s multi-module one, while the IDE is closed of course).

      So it’s much better to go with a new project and configure it from scratch (most of the config files can be copied over from old .idea into the new one).

    Anyway, the overall idea is as follows:

    1. In your IDE, create a new project where you want to keep your .idea — lets assume this will be C:JetBrainsProjectsStoreMyProject.

    2. Go to the project settings and find a place where you configure your Content Roots. In PhpStorm/WebStorm this will be Settings/Preferences | Directories.

    3. Remove existing Content Root (by default every project has one). In our example this will be the aforementioned C:JetBrainsProjectsStoreMyProject folder.

    4. Add a New Content Root instead: point it to the folder where your project files actually are (or where you want to keep them). Lets assume this will be C:ProjectsMyActualProject.

    5. Save. That’s it (well, repeat steps 3-4 for other modules if your project has them).

    Now your project config is stored in C:JetBrainsProjectsStoreMyProject.idea while the actual code files are in C:ProjectsMyActualProject.

    Obviously, if you now need to use Open in the IDE to open a project or open it from the command line, you need to use the parent folder where the actual .idea is — C:JetBrainsProjectsStoreMyProject.


    There is a ticket that asks for the same: https://youtrack.jetbrains.com/issue/IDEA-1701022. Watch it (star/vote/comment) to get notified with any progress.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search