.gradle文件夹是否应该添加到版本控制中? [英] Should the .gradle folder be added to version control?

查看:1134
本文介绍了.gradle文件夹是否应该添加到版本控制中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Gradle创建一个名为 .gradle 的文件夹。我应该使用我的版本控制(即git)来跟踪它吗?

更重要的是,为什么/为什么不呢?

解决方案

我应该跟踪.gradle目录吗?

不。它可以安全地被忽略。






为什么要忽略它?



这纯粹是为了缓存信息,你不希望它在你的回购中,因为:




  • 它可能变得很大并且充满二进制文件

  • 那里可能有机器特定的数据

  • 那里有很多流失不断地对文件进行更改)










  • $ b $

    它基本上是一个临时目录,Gradle在您的源代码中间放下(为什么Gradle认为这是一个合适的事情是一个不同的问题)。

    您可以通过交换机的名称来告诉目录的缓存目录性质,该名称可以更改它的位置: - project-cache-d IR



    虽然我讨厌在源代码树中使用二进制文件,但我通常最终只会将目录添加到我的忽略文件中,因为沿线的某处我会忘记使用从某些命令行切换或从我的IDE切换,然后最终不得不处理目录。






    我该如何忽略它?

    Git用户可以将 .gradle 添加到 .gitgnore 文件,Git将忽略任何具有该名称的目录中的所有文件。

    Mercurial用户希望查找 .hgignore 档案。



    其他版本控制系统,参考文档 - 他们都有一个功能来支持这一点。


    Gradle creates a folder called .gradle. Should I track it with my version control (i.e. git)?

    More importantly, why / why not?

    解决方案

    Should I track the .gradle directory?

    No. It can safely be ignored.


    Why should I ignore it?

    It's purely for caching information, you don't want it in your repo because:

    • it can get big and be full of binary files
    • there can be machine specific data in there
    • there's a lot of churn in there (you'd be constantly committing changes to files in there)
    • everything in there can be completely re-generated whenever it is needed anyway

    It's basically a temp directory that Gradle is dropping in the middle of your source code (why Gradle thinks that's an appropriate thing to do is a different question).

    You can tell the "cache directory" nature of the directory by the name of the switch that lets you change where it goes: "--project-cache-dir".

    Though I hate having binary files in my source tree, I usually just end up adding the directory to my ignore file because somewhere along the line I'll forget to use the switch from some command line or from my IDE or something and then end up having to deal with the directory anyway.


    How do I ignore it?

    Git users can add a line with just .gradle to the .gitgnore file and Git will ignore all files in any directory with that name.

    Mercurial users want to look up the .hgignore file.

    For other version control systems, refer to the documentation - they all have a feature to support this.

    这篇关于.gradle文件夹是否应该添加到版本控制中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆