git IntelliJ IDEA 中 Scala/sbt 项目推荐的 .gitignore 是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24297331/
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
What's recommended .gitignore for Scala/sbt project in IntelliJ IDEA?
提问by anshumans
I created a new Scala/sbt project in IntelliJ IDEA 13. Since other team members will be working on this project (presumably with other IDEs), what should I put in the .gitignore
? It seems some of the project dependencies are defined in the .idea
folder, so I wasn't sure if I can put the whole directory in .gitignore
or not.
我在 IntelliJ IDEA 13 中创建了一个新的 Scala/sbt 项目。由于其他团队成员将在这个项目上工作(大概是使用其他 IDE),我应该在.gitignore
? 似乎.idea
文件夹中定义了一些项目依赖项,所以我不确定是否可以将整个目录放入.gitignore
。
回答by aa333
EDIT After discovering Joe:
发现 Joe 后编辑:
Just ask Joeto take care of your .gitignore
请乔照顾你.gitignore
Original Answer:
原答案:
Since you're using Scala you should add:
由于您使用的是 Scala,因此您应该添加:
target
*.class
These can be generated back easily and could be machine dependent.
这些可以很容易地生成回来,并且可能依赖于机器。
If you're going to use IntelliJ then the following:
如果您打算使用 IntelliJ,则以下内容:
*.iml
*.ipr
*.iws
.idea
out
The .idea folder and the .iml files are created and used only by IntelliJ, other IDEs will just ignore them. They can be generated easily by IntelliJ if needed, try deleting your .idea folder and then open the project in IntelliJ and, lo and behold the first thing it does is generate the .idea folder and it's contents.
.idea 文件夹和 .iml 文件仅由 IntelliJ 创建和使用,其他 IDE 将忽略它们。如果需要,IntelliJ 可以轻松生成它们,尝试删除您的 .idea 文件夹,然后在 IntelliJ 中打开项目,瞧,它做的第一件事就是生成 .idea 文件夹及其内容。
For Vim:
对于 Vim:
tags
.*.swp
.*.swo
For Eclipse(Scala IDE):
对于 Eclipse(Scala IDE):
build
.classpath
.project
.settings
org.scala-ide.sdt.core/META-INF/MANIFEST.MF
org.scala-ide.sdt.update-site/site.xml`
For macOS:
对于 macOS:
.DS_Store
I think this covers the most popular IDEs for Scala. If someone's using an IDE not covered, you'll have to look around for what temporary and build files they create.
我认为这涵盖了 Scala 最流行的 IDE。如果有人使用未涵盖的 IDE,您将不得不四处寻找他们创建的临时文件和构建文件。
回答by Chris
Here's what gitignore.iosuggests for Scala and sbt:
这是gitignore.io对 Scala 和 sbt 的建议:
# Created by https://www.gitignore.io/api/sbt,scala
### SBT ###
# Simple Build Tool
# http://www.scala-sbt.org/release/docs/Getting-Started/Directories.html#configuring-version-control
dist/*
target/
lib_managed/
src_managed/
project/boot/
project/plugins/project/
.history
.cache
.lib/
### Scala ###
*.class
*.log
# End of https://www.gitignore.io/api/sbt,scala
I usually recommend putting IDE / editor ignores into .git/info/exclude
if you've got a mix of editors. This is a personal ignore file that does not get committed with the repository.
.git/info/exclude
如果您有多种编辑器,我通常建议将 IDE / 编辑器忽略。这是一个个人忽略文件,不会与存储库一起提交。
gitignore.io has suggestions for IDEs and editors too:
gitignore.io 也有对 IDE 和编辑器的建议: