歡迎光臨
每天分享高質量文章

Java 開發 .gitignore 檔案包含 .iml,.log 的看法

(點選上方公眾號,可快速關註)


來源:乞力馬扎羅的雪雪,

blog.csdn.net/chenyufeng1991/article/details/78243849

有一個開源專案主要用來規範所有開發專案的.gitignore檔案的編寫,基本涵蓋了所有的開發語言、開發環境等。今日我向JetBrains.gitignore提交了一個pull request,希望能在這個檔案中增加.iml、.log兩行程式碼的支援,引起了一場討論。提交的pull request為: 

https://github.com/github/gitignore/pull/2418

開源專案

https://github.com/github/gitignore 

而JetBrains官方也對相關檔案是否應該加到.gitignore中給出了意見 。官方的一些解釋如下:

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中。

All the .iml module files that can be located in different module directories(applies to IntelliJ IDEA)

所有的.iml檔案都應該共享,因為這些檔案定位了不同的module目錄。

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的時候生成。

gradle.xml file, see this discussion

gradle.xml檔案也不應該被分享。

user dictionaries folder (to avoid conflicts if other developer has the same name)

使用者的目錄檔案夾也不應該被分享。

XML files under .idea/libraries in case they are generated from Gradle or Maven project

.idea/libraries目錄下的XML檔案也不應該分享,因為它們是由gradle、maven生成的。

其實看了官方的關於.iml的說明,我還是不明白到底是否應該把.iml新增到.gitignore中,感覺官方的解釋比較模糊。在有些評論中,開發者建議對於一些檔案,可以設定一個local目錄,在local目錄中的檔案是不需要被分享的。各位客官怎麼看呢?

看完本文有收穫?請轉發分享給更多人

關註「ImportNew」,提升Java技能

贊(0)

分享創造快樂