github/gitignore · Kotlin.gitignore

Kotlin .gitignore Template Explained

Why Kotlin.gitignore ignores JVM output such as .class and jar files and the Kotlin 2.0 .kotlin directory, and what to watch for when combining it with the Gradle and Android templates.

Open in generator Open with Gradle, Android, JetBrains, macOS

Kotlin.gitignore is the Java template's rules plus the .kotlin/ directory used by the Kotlin Gradle plugin. Compiling Kotlin/JVM code produces the same .class and .jar files as Java.

It contains no build-tool rules. Most Kotlin projects use Gradle, so pick the Gradle template as well, or the Android template for Android apps.

Rules explained

PatternWhat it ignores and why
.kotlin/Kotlin Gradle plugin dataStarting with Kotlin 2.0, the Gradle plugin stores data such as session information and error logs in a .kotlin folder at the project root. The Kotlin documentation also says to add this folder to .gitignore.
*.class*.jar*.war*.nar*.ear*.zip*.tar.gz*.rarCompilation output and archivesJVM bytecode and distribution archives. They can be rebuilt from the source and build scripts alone.
hs_err_pid*replay_pid*JVM crash logsDiagnostic files left when the JVM terminates abnormally.
*.log*.ctxt.mtj.tmp/OtherRun logs and BlueJ/J2ME tool files. These rules are inherited unchanged from the Java template.

Practical notes

Original template

Kotlin.gitignore14 rules
# Compiled class file*.class# Log file*.log# BlueJ files*.ctxt# Mobile Tools for Java (J2ME).mtj.tmp/# Package Files #*.jar*.war*.nar*.ear*.zip*.tar.gz*.rar# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xmlhs_err_pid*replay_pid*# Kotlin Gradle plugin data, see https://kotlinlang.org/docs/whatsnew20.html#new-directory-for-kotlin-data-in-gradle-projects.kotlin/

Templates from github/gitignore/Kotlin.gitignore @356fd7b (2026-09-11) · CC0-1.0

Often used together

More template explanations