86

I read about Git integration in PyCharm, and created a Git repository from PyCharm. I did this in PyCharm because I was hoping PyCharm would know whether the .idea folder should be ignored, and if that's the case, it would automatically create a .gitignore file with the line .idea/ in it.

But it didn't, so I assumed that I shouldn't ignore the .idea foler. However, I did a quick search and found someone's example .gitignore file, here, which clearly ignores the .idea folder.

So, my question is, should the .idea folder be ignored or not?

Stevoisiak
  • 23,794
  • 27
  • 122
  • 225
Ray
  • 7,833
  • 13
  • 57
  • 91
  • since by and large you can just open a folder as a project in pycharm I would say you certainly dont need it under revision control... that said it wouldn't hurt either(ie no negative repercussions from putting it in git, other than potentially revealing some of your folder structure to the world) – Joran Beasley Jul 01 '14 at 18:40
  • http://stackoverflow.com/questions/5039442/pycharm-and-source-control-the-idea-directory-commit-or-not-commit-that-is-t – Mauricio Scheffer Sep 24 '15 at 09:25
  • 1
    Possible duplicate of [Should the .idea folder be kept under source control?](http://stackoverflow.com/questions/5362816/should-the-idea-folder-be-kept-under-source-control) – NoDataDumpNoContribution May 24 '16 at 17:43
  • Related: [Intellij Idea 9/10, what folders to check into (or not check into) source control?](https://stackoverflow.com/q/3041154/3357935) – Stevoisiak Mar 12 '18 at 14:36
  • **Note:** [IntelliJ's documentation](https://intellij-support.jetbrains.com/hc/en-us/articles/206544839) explicitly warns **against** sharing `workspace.xml`. Refer to answers by [myself](https://stackoverflow.com/a/49238133/3357935) or [Artem](https://stackoverflow.com/a/40092361/3357935) for more detail. – Stevoisiak Mar 12 '18 at 14:55
  • see which files that [gitignore.io recommends](https://www.gitignore.io/api/intellij) for the IntelliJ platform – ddavison Mar 12 '18 at 15:30

6 Answers6

43

Ignoring the whole .idea folder is not necessarily the best idea. There's a number of similar discussions here about this.

But I suggest to check the official FAQ on this matter.

Community
  • 1
  • 1
Topka
  • 2,001
  • 16
  • 13
  • **Note:** [IntelliJ's documentation](https://intellij-support.jetbrains.com/hc/en-us/articles/206544839) explicitly warns **against** sharing `workspace.xml`. Refer to answers by [myself](https://stackoverflow.com/a/49238133/3357935) or [Artem](https://stackoverflow.com/a/40092361/3357935) for more detail. – Stevoisiak Mar 12 '18 at 14:56
  • 6
    this is not a good answer. First all the things you provide are links (that can break in the future). Second, it puts the work on the reader than actually being an answer in the answer response spirit of SO. – Charlie Parker Feb 07 '22 at 21:11
  • This is such a non-answer. To add my two cents I personally exclude the .idea folder and if there's anything specifically within it that others need I will check those files and commit them specifically. I ascribe to the idea that the minimally needed files are better than putting everything in, in regards to git. – MarMar Mar 28 '23 at 19:00
37

All the settings files in the .idea directory should be put under version control except the workspace.xml, which stores your local preferences. The workspace.xml file should be marked as ignored by VCS.

-PyCharm 2017.3 project documentation

To explain further, workspace.xml contains user-specific workspace preferences. This includes environment variables, recently accessed files, and cursor position.

Artem Zaytsev
  • 1,621
  • 20
  • 19
13

While sharing your project settings isn't inherently a bad idea, there are several exceptions and potential issues you should be aware of.

  • The workspace.xml file contains various user-specific settings, such as environment variables, cursor position, and Python SDK location.
    • Environmental variables may include private data, such as usernames and passwords
  • The dictionaries folder contains custom spellings, which can cause conflicts if two developers have the same name.
  • The .idea folder is PyCharm specific, meaning developers using a different IDE can lead to project desynchronization.
  • IntelliJ's own documentation includes several warnings for specific files that shouldn't be shared.

If you do decide to share .idea, IntelliJ's official documentation gives the following advice

[The .idea] format is used by all the recent IDE versions by default. Here is what you need to share:

  • All the files under .idea directory in the project root except the workspace.xml and tasks.xml files which store user specific settings
  • All the .iml module files that can be located in different module directories (applies to IntelliJ IDEA)

Be careful about sharing the following:

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

You may consider not to share the following:

  • .iml files 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

Source: JetBrains - How to manage projects under Version Control Systems

Stevoisiak
  • 23,794
  • 27
  • 122
  • 225
  • 3
    I believe most of these issues will be addressed if you use Jetbrains's gitingore file. https://github.com/github/gitignore/blob/master/Global/JetBrains.gitignore – Poulad Sep 05 '19 at 13:53
3

I found some issue when include whole .idea/ directory into project.

If you push to git repo including .idea/ directory, and clone that project on other machine with pycharm, pycharm can't recognize the project appropriately.

After delete .idea/ directory, pycharm recognize the project well.

minsu
  • 81
  • 5
1

The .idea/ folder is just the way that JetBrain's stores data. It's in IntelliJ and PyCharm, so, yes, it can be ignored.

Jake
  • 407
  • 4
  • 13
  • 1
    I don't agree http://stackoverflow.com/questions/24516814/pycharm-with-git-shall-i-ignore-the-idea-folder#comment67434330_24516850 – Nam G VU Oct 17 '16 at 07:35
1

For the freshest of clean starts, don't store .idea in version control.

I was doing this for years and it was a hassle setting up for a new IDE/machine as projects became more complicated. I'm happy to have learned how to, safely.

Based on advice above I was going to .gitignore just .idea/workspace.xml, down from .idea, previously.

Though it doesn't show up in PyCharm's explorer, the .idea folder is pre-populated with its own .gitignore which I can count on being maintained along with the IDE itself. I don't need to explicitly .gitignore any of its path, as it takes care of itself.

Here are its contents:

# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

If I had anything sensitive in there I would still double check my git commits, but we already do, right?

John
  • 6,433
  • 7
  • 47
  • 82