Search code examples
intellij-ideagitignore

IntelliJ Generates a .gitignore file inside .idea folder eventhough my project already has .gitignore file in project root folder


I am switching to using Git for my projects and I generate my .gitignore file by going to gitignore.io page and entering my tech stack (for example, IntelliJ, Java).

This auto generates .gitignore file for IntelliJ and Java technologies and I paste this file in the root of my project like:

MyProject
- .idea
- fileA
- fileB
- ...
- .gitignore

However, I just opened my project and IntelliJ prompts me to add files to .idea folder. These files are:

  1. .gitignore
  2. compiler.xml
  3. encodings.xml
  4. jarRepositories.xml
  5. misc.xml
  6. vcs.xml

I have 2 questions:

  1. Why is IntelliJ creating .idea/.gitignore file if I already have my .gitignore file in my project root?
  2. What are the other files and should they be ignored?

Solution

  • I got answer to this from JetBrains community at https://intellij-support.jetbrains.com/hc/en-us/community/posts/12550701430034-Why-is-IntelliJ-creating-a-gitignore-file-in-idea-folder-even-though-I-have-gitignore-file-in-my-project-root-and-should-it-be-ignored-or-committed-to-repository-?page=1#community_comment_12611700355346

    TLDR: Yes, the .idea/.gitignore should be included in repo as it is used for ignoring some internal IntelliJ folders.

    About the other files, information is in the link above