有一个开源项目https://github.com/github/gitignore 主要用来规范全部开发项目的.gitignore文件的编写,基本涵盖了全部的开发语言、开发环境等。今日我向JetBrains.gitignore提交了一个pull request,但愿能在这个文件中增长.iml、.log两行代码的支持,引发了一场讨论。提交的pull request为:https://github.com/github/gitignore/pull/2418 。
而JetBrains官方也对相关文件是否应该加到.gitignore中给出了意见,官方建议在此:https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 。官方的一些解释以下:git
This 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 andtasks.xml files which store user specific settings
.idea目录中除了workspace.xml和tasks.xml不须要在开发者之间共享,由于这两个文件保存了用户特定的信息。其余的都应该共享。因此workspace.xml和tasks.xml能够写到.gitignore中,其余的不要写到.gitignore中。github
All the .iml module files that can be located in different module directories(applies to IntelliJ IDEA)
全部的.iml文件都应该共享,由于这些文件定位了不一样的module目录。app
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、Maven的项目中的.iml文件,由于这些文件会在import的时候生成。maven
gradle.xml file, see this discussion
gradle.xml文件也不该该被分享。ide
user dictionaries folder (to avoid conflicts if other developer has the same name)
用户的目录文件夹也不该该被分享。gradle
XML files under .idea/libraries in case they are generated from Gradle or Maven project
.idea/libraries目录下的XML文件也不该该分享,由于它们是由gradle、maven生成的。this
其实看了官方的关于.iml的说明,我仍是不明白究竟是否应该把.iml添加到.gitignore中,感受官方的解释比较模糊。在有些评论中,开发者建议对于一些文件,能够设置一个local目录,在local目录中的文件是不须要被分享的。各位客官怎么看呢?idea
做者:乞力马扎罗的雪CYF
来源:CSDN
原文:https://blog.csdn.net/chenyufeng1991/article/details/78243849spa