Which files in .idea folder should be tracked by G

2019-02-05 22:02发布

Unlike Netbeans, in Jetbrains IDEs, the setting files related to user and team are mixed in the same folder that make it a 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 using IDE auto-reformatting option all team will follow a consistent style.

Beside that, the question is that which other files are recommenced to be included not ignored? Why?

answer: I came up with this: https://github.com/salarmehr/idea-gitignore

5条回答
The star\"
2楼-- · 2019-02-05 22:28

I prefer not to check in the .idea folder or .iml files at all.

  • If you want to share editor styles, consider using a .editorconfig file, the JetBrains IDEs support these now.
  • For other things, like build settings you could try to lean on your build tool, e.g. use maven or gradle build files to carry specific setups.
  • Obviously there's a bunch of other things that won't be covered, but most of them can be solved by well documented conventions.
查看更多
倾城 Initia
3楼-- · 2019-02-05 22:30

After some investigation I came up with the following .idea/.gitignore file:

# ignore all .idea files ...
*
# except  ...

# Version Control configuration
!vcs.xml

# how IDEA should treat the text files
!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.

answer: I came up with this: https://github.com/salarmehr/idea-gitignore

查看更多
Juvenile、少年°
4楼-- · 2019-02-05 22:45

I use both IDEA and Eclipse, but not Netbeans. I never commit any project files but make sure that I have a Maven build as the leading tool, then I can easily import the Maven project into any IDE with Maven support and also refresh from Maven once I change it. For Eclipse and IDEA this works beautifully.

My .gitignore file looks like this for all of my projects:

# Eclipse
.settings/
.classpath
.project

# IntelliJ IDEA
.idea/
*.iml

# Maven
target/

Plus other, project-specific files or directories.

查看更多
该账号已被封号
5楼-- · 2019-02-05 22:49

It's recommended not to commit all the .idea folder because it's for configurations. Like the *.iml file.

If I use Netbeans instead of Intellij, I don't want these config files. It is useless and maybe a little dangerous for conflicts.

查看更多
冷血范
6楼-- · 2019-02-05 22:54

Jetbrains has some official guidance on which files should not be checked in, and which files should probably not be checked in, depending on your usage. According to that page, you should check in all files in the .idea directory except:

  • workspace.xml
  • tasks.xml

And probably also:

  • the xml files in the dictionary subdirectory

While the particular answer may depend on your team's particular practices, in my experience, following that guidance generally results in correct separation of user settings and shared project configuration.

Some examples of files that should be shared, according to this guidance:

  • ant.xml, which, if you use Ant to build your project, points IDEA to your build files and configures properties that should be used to build.
  • vcs.xml, which specifies the Version Control configuration for your project
  • encodings.xml, which specifies how IDEA should treat the text files in your project
  • modules.xml, which points IDEA to each of your project's module configuration files, which should also be shared in your VCS.
  • all files under the runConfigurations subdirectory, which tells IDEA what it needs to do to run your application
  • codeStyleSettings.xml, which, as you have alluded to, puts your whole team on the same page in terms of automatic code formatting

Depending on your team's usage, there may be more or less, but those are some of the biggest examples.

查看更多
登录 后发表回答