1

Pycharm generates a .idea directory at the root of a Pycharm project. What files/directories within .idea should be ignored by git in this directory? Is this properly handled by the .gitignore file automatically generated within .idea:

cat .idea/.gitignore
# Default ignored files
/shelf/
/workspace.xml

or do I need to add something to the project root's .gitignore file?

rhz
  • 960
  • 14
  • 29
  • 2
    Does this answer your question? [What to gitignore from the .idea folder?](https://stackoverflow.com/questions/11968531/what-to-gitignore-from-the-idea-folder) – Gino Mempin Dec 29 '20 at 04:54

1 Answers1

2

In general, you should not check in any files to the repository which are specific to your editor or IDE unless they are also absolutely required to build the project. So if you're using PyCharm for development, all of the files it generates should be ignored.

The reason is that on most projects with multiple developers, different people will use different editors. So while you use PyCharm, I might use Vim. We don't want our .gitignore to have to learn about every user's preferred editor files, and we don't want to have to maintain multiple sets of editor files, especially since we may work on multiple projects together. If we need to configure settings, it's better to use an .editorconfig file, which works across editors, or prefer a standardized set of tools, such as a code formatter (and check in any configuration we need for that).

Instead, you should configure core.excludesfile (or use the default, $HOME/.config/git/ignore) so that it excludes your editor files. This works for all repositories that you use so each project doesn't have to learn about those settings and lets you change one place if you change editors. So in this case, that means adding the /.idea line to that file.

bk2204
  • 64,793
  • 6
  • 84
  • 100
  • While I completely agree with this answer in general, it looks like some files in `.idea` should be shared (e.g., shared dictionaries -- it also demonstrates that the design of the `.idea` directory and user workspace files has some design flaws). But I still use `.idea` in `.gitignore` because of that. – terrorrussia-keeps-killing Dec 29 '20 at 07:25