Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's recommended .gitignore for Scala/sbt project in IntelliJ IDEA?

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.

like image 235
anshumans Avatar asked Jun 19 '14 01:06

anshumans


People also ask

How do I get the .gitignore file in IntelliJ?

gitignore file in the VCS root directory, you can right-click anywhere in the Project window, choose New | File and type . gitignore in the New File dialog.

How compile sbt project in IntelliJ?

Press Ctrl+Alt+S to open the IDE settings and select Build, Execution, Deployment | Build Tools | sbt. In the sbt projects section, select a project for which you want to configure build actions. In the sbt shell section, select the builds option. Click OK to save the changes.


2 Answers

EDIT After discovering Joe:

Just ask Joe to take care of your .gitignore

Original Answer:

Since you're using Scala you should add:

target *.class 

These can be generated back easily and could be machine dependent.

If you're going to use IntelliJ then the following:

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

For Vim:

tags .*.swp .*.swo 

For 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:

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

like image 195
aa333 Avatar answered Sep 19 '22 12:09

aa333


Here's what gitignore.io suggests for Scala and 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.

gitignore.io has suggestions for IDEs and editors too:

  • IntelliJ, which does recommend ignoring the entire .idea directory
  • Eclipse
  • Vim
  • Emacs
like image 25
Chris Avatar answered Sep 19 '22 12:09

Chris