Android工作室 - 整个.idea目录应该在git忽略? [英] Android studio - should the entire .idea directory be in git ignore?

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

问题描述

我发现了很多针对 AndroidStudio .gitignore 文件的示例,其中一些包含 .idea

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



如果不应该完全忽略,那么.idea(例如.iml)里面应该有.gitignore中的特定文件吗?

解决方案

您可以查看此页面: a href =https://www.jetbrains.com/help/idea/2017.1/about-projects.html =noreferrer>关于项目配置文件的IntelliJ文档



在基于目录的格式中,特定的行很有趣:


.idea目录包含一组配置文件(.xml)。每个文件仅包含一部分与某个功能区有关的配置数据,这些配置数据反映在文件的名称中,例如 compiler.xml encodings.xml modules.xml



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


但是,我正确地HATE使项目IDE依赖(我目前正在使用NetBeans制作的项目,并且使用它成为我公司的标准)。因此,要回答您的问题:


  1. 如果您使用不要使用像Maven或Gradle这样的东西来管理依赖关系并构建:将目录保留在版本控制下。这样,项目和依赖关系的正确配置将适用于每个人。在对应中,所有开发人员必须完全按照您在配置文件中定义它的方式来设置它们的环境。

  2. 如果确实使用或Gradle:正确配置这些工具并不要将目录保留在版本控制下。实际上,配置文件中包含的所有信息都应该存储在Maven / Gradle文件中。然后让开发人员根据其环境配置他们的IDE。这样,使用Eclipse,IntelliJ,Linux,Windows ...将不再成为问题。


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

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

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

解决方案

You can take a look at this page :

IntelliJ doc about project configuration files

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

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.

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).

So, to answer your question :

  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工作室 - 整个.idea目录应该在git忽略?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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