git 为什么 .iml 文件应该添加到 gitignore?一般情况下应该在gitignore中放置什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30674208/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 11:05:28  来源:igfitidea点击:

Why .iml files should be added to gitignore? What should be placed in gitignore in common case?

gitintellij-idea

提问by QuestionAndAnswer

Primary question is, why should I add IDEAs *.iml files to gitignore? If then I get repo without .iml file, I will forced to create new project and manualy add my files. Am I wrong about it?

主要问题是,为什么我应该将 IDEAs *.iml 文件添加到 gitignore?如果然后我得到没有 .iml 文件的 repo,我将被迫创建新项目并手动添加我的文件。我错了吗?

Actualy, my question is slightly wider. Where can I found more information about what should I do for different languages and IDE's. Maybe there are some general rules when creating new repository for first time used language?

实际上,我的问题稍微宽泛一些。我在哪里可以找到有关我应该为不同的语言和 IDE 做什么的更多信息。在为首次使用的语言创建新存储库时,也许有一些通用规则?

回答by Peter Lawrey

why should I add IDEAs *.iml files to gitignore?

为什么我应该将 IDEAs *.iml 文件添加到 gitignore?

These files get changed all the time when it has nothing to do with the code. If you are not careful you will always be merging this file with every check in with other developers.

当这些文件与代码无关时,它会一直被更改。如果您不小心,您将始终在与其他开发人员签入时合并此文件。

If then I get repo without .iml file, I will forced to create new project and manualy add my files. Am I wrong about it?

如果然后我得到没有 .iml 文件的 repo,我将被迫创建新项目并手动添加我的文件。我错了吗?

Not if you use a build tool like maven, gradle or ant. These are better options and work outside IntelliJ.

如果您使用 maven、gradle 或 ant 等构建工具,则不会。这些是更好的选择并且可以在 IntelliJ 之外工作。

Where can I found more information about what should I do for different languages and IDE's.

我在哪里可以找到有关我应该为不同的语言和 IDE 做什么的更多信息。

Use Google or if you have a specific question, Stack Overflow.

使用谷歌或者如果你有一个特定的问题,堆栈溢出。

Maybe there are some general rules when creating new repository for first time used language?

在为首次使用的语言创建新存储库时,也许有一些通用规则?

There are a lot of standards, take your pick. I suggest you have a look at how projects which are similar to yours have been setup.

有很多标准,你自己挑吧。我建议您看看与您的项目相似的项目是如何设置的。