Search code examples
gitpycharmgitignorejetbrains-ide

What is the most up-to-date best practice for version controlling JetBrains .idea files?


This applies to all of their products (IntelliJ, PyCharm, Clion, etc)

They change their config files so often that most .gitignore files aren't up to date anymore.

I'm currently ignoring the entire .idea directory, but I think it still makes sense to version control certain stuff that should be consistent across machines and different people working on the same project.

Ideally, I'd like to keep at least code style and project structure related files. Any advice?


Solution

  • In general, you want to exclude any editor-specific files from version control. The reason is that in general, different people will use different editors and maintaining a set of configuration files, one per editor, is a recipe for disaster.

    Only if you are certain that everyone will be using the same editor (e.g., because of a company mandate) should you check any of these in. However, absent a very compelling reason, developers should be free to use the editor of their choice on the project, so the above applies.

    You should however, include config files that are cross editor, like EditorConfig files (which these programs should support natively), build files, and linter or code formatter files. In general, those config files will apply to people using any editor, and for the linter and code formatter files, can be run in CI to verify that code is formatted or linted correctly.