Android studio - 整个 .idea 目录应该在 git ignore 中吗? [英] Android studio - should the entire .idea directory be in git ignore?

查看:22
本文介绍了Android studio - 整个 .idea 目录应该在 git ignore 中吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到了很多 AndroidStudio.gitignore 文件示例,其中有些包含 .idea,有些则没有.

I saw a lot of examples for .gitignore files for AndroidStudio, some have .idea in them, and some don't.

是否有充分的理由不将整个 .idea 目录添加到 .gitignore?

Is there a good reason not to add the entire .idea dir to .gitignore?

如果不应该完全忽略,.idea 中是否有特定文件(例如 .iml)应该在 .gitignore 中?

If it should not be completely ignored, are there specific files inside .idea (such as .iml) that should be in .gitignore?

推荐答案

你可以看看这个页面:

关于项目配置文件的 IntelliJ 文档

在基于目录的格式"中,有一行很有趣:

In the "Directory-based format", a particular line is interesting :

.idea 目录包含一组配置文件 (.xml).每个文件只包含与某个功能区相关的一部分配置数据,反映在文件名中,例如,compiler.xmlencodings.xmlmodules.xml.

The .idea directory contains a set of configuration files (.xml). Each file contains only a portion of configuration data pertaining to a certain functional area which is reflected in the name of a file, for example, compiler.xml, encodings.xml, modules.xml.

几乎所有文件都包含项目本身的核心信息,例如其组件模块的名称和位置、编译器设置等.因此,这些文件可以(并且应该)保持在版本控制之下.

Almost all of the files contain information core to the project itself, such as names and locations of its component modules, compiler settings, etc. Thus, these files may (and should) be kept under version control.

但是,我非常讨厌使项目依赖于 IDE(我目前正在开发一个用 NetBeans 制作的项目,将它与成为我公司标准的 Eclipse 一起使用会很痛苦).

However, I properly HATE to make project IDE-dependent (I am currently working on a project made with NetBeans and it hurts to use it with Eclipse which becomes the standard of my company).

所以,回答你的问题:

  1. 如果您不使用诸如 Maven 或 Gradle 之类的工具来管理依赖项和构建:将目录置于版本控制之下.这样,每个人都可以使用正确的项目配置和依赖项.相反,所有开发人员都必须按照您在配置文件中定义的方式完全相同地设置他们的环境.
  2. 如果您确实使用诸如 Maven 或 Gradle 之类的工具:正确配置这些工具并且不要将目录置于版本控制之下.实际上,包含在配置文件中的所有信息应该存储在 Maven/Gradle 文件中.然后让您的开发人员根据他们的环境配置他们的 IDE.这样,使用 Eclipse、IntelliJ、Linux、Windows ... 将不再是问题.
  1. If you do not use something like Maven or Gradle to manage dependencies and build : keep the directory under version control. This way, the correct configuration of the project and dependencies will be available for everyone. In the counterpart, all developers will have to set their environment exactly the same way that you define it in the config files.
  2. If you do use something like Maven or Gradle : correctly configure these tools and do not keep the directory under version control. Actually, all the information contained inside config files should be stored in Maven/Gradle files. Then let your developers configure their IDE depending of their environment. This way, using Eclipse, IntelliJ, Linux, Windows ... will not be a problem anymore.

这篇关于Android studio - 整个 .idea 目录应该在 git ignore 中吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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