Java开发.gitignore文件包含.iml,.log的看法

本文讨论了在.gitignore文件中包含.iml文件的争议, JetBrains官方建议仅将workspace.xml和tasks.xml添加到.gitignore中,而.iml文件应在特定条件下排除。基于此,作者在GitHub上提交了一个Pull Request,引发了社区讨论。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

有一个开源项目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  。官方的一些解释如下:


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目录中的文件是不需要被分享的。各位客官怎么看呢?
---------------------
作者:乞力马扎罗的雪CYF
来源:优快云
原文:https://blog.youkuaiyun.com/chenyufeng1991/article/details/78243849

 

更多精彩干货详情可关注二维码回复“干货”即可获取

转载于:https://www.cnblogs.com/xdclass/p/9835006.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值