A sample .gitignore file for Scala/sbt projects

As a brief note today, this is a sample Git .gitignore file that I use for Scala projects, including Scala CLI projects, sbt projects, and using VS Code or IntelliJ IDEA as your IDE:

# scala-cli, bloop, metals
.bsp/
.bloop/
.metals/
.scala-build/
project/metals.sbt

# vs code
.vscode/

# scala 3
.tasty

# sbt
project/project/
project/target/
target/

# eclipse
build/
.classpath
.project
.settings
.worksheet
bin/
.cache

# intellij idea
*.log
*.iml
*.ipr
*.iws
.idea

# mac
.DS_Store

# other?
.history
.scala_dependencies
.cache-main

# general
*.class

I’ll update this file over time, but for now I just want to put an example gitignore file out here so I don’t have to try to remember which gitignore file I created last.

One final note: Some of those files/directories are unique to SBT, some are for IntelliJ IDEA, others are for Scala/Eclipse, and .DS_Store is Mac-specific. Use whatever you want/need.

Some of this is counter to recommendations, so buyer beware. More info: