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.
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
| Pattern | What 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*.rar | Compilation 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
- To keep
*.jarfrom ignoring the Gradle wrapper jar, place the Gradle template after Kotlin so that!gradle-wrapper.jaris applied last. - If you target iOS with Kotlin Multiplatform, you also need Xcode/Swift-related rules and the macOS template.
- Handle IntelliJ IDEA settings with the JetBrains template.
Original template
Kotlin.gitignore
# 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