gitintellij-ideaphpstormignore

Which files in .idea folder should be tracked by Git?


Unlike Netbeans, in Jetbrains IDEs, the setting files related to user and team are mixed in the same folder that makes it tricky when you need to push them to git.

There is a number of sample git ignore files for these IDEs and https://intellij-support.jetbrains.com/hc/articles/206544839 page on git site.

However, after using them for a months we figure out that it is safer and actually more convenient to do the reverse. I mean ignoring all .idea files and adding only team-related settings explicitly. (instead of adding all and ignoring some).

The main thing that can be shared among developers is code style configs. So, by using IDE auto-reformatting option all the team will follow a consistent style.

Besides that, the question is which other files are recommended to be included and not ignored? Why?

Answer: I came across with this: https://github.com/salarmehr/idea-gitignore


Solution

  • I found the whitelist startegy indicated here suitable for most projects https://github.com/salarmehr/idea-gitignore, so you create/modify .idea/.gitignore as below.

    #### ignore all .idea files ...
    *
    
    #### except
    
    # Version Control configuration for your project
    !vcs.xml
    
    # how IDEA should treat the text files in your project
    !encodings.xml
    
    # automatic code formatting
    !codeStyleSettings.xml
    
    # project specific words
    !dictionaries
    
    !copyrights
    !misc.xml
    !sqldialects.xml
    

    Above files should practically be identical for all team members.