Java開發.gitignore文件包含.iml,.log的見解

有一個開源項目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

相關文章
相關標籤/搜索