IntelliJ IDEA .gitignore template
The IntelliJ template ignores the editor's project directory wholesale, along with module and workspace files and several plugin generated configuration files.
At a glance
- Category
- IDE
- Patterns in this template
- 11 rules
- Directories ignored
- 3 of the 11 rules end in a slash, so they match directories only
- Also needs an OS template
- Yes. This covers the editor only.
- Typical companions
- The language template for your project, plus an OS template.
In detail
.idea is the project directory the editor creates, and this template ignores all of it. That is the blunt option, and it is defensible: the directory mixes genuinely shared configuration, such as code style and inspection profiles, with pure session state, such as which files you had open and where your breakpoints are, and separating them takes a list of negations that has changed with every editor version.
The cost is that a team giving up on the directory also gives up on sharing a code style. The usual replacement is a formatter configuration file that lives outside the editor directory and that other tools read too, which sidesteps the argument entirely.
The module files are the other half. *.iml describes one module: its source roots, its dependencies and its language level. *.iws is the workspace, holding entirely personal state. *.ipr is the older single file project format. In a project built by a real build tool, the module files are regenerated on import, so tracking them means constant conflicts over machine specific paths.
out is the compiler output directory the editor uses when it compiles a project itself rather than delegating to the build tool. It is the editor's equivalent of a build directory and it is regenerated on demand. Because the rule is unanchored, it also matches a source directory named out anywhere in the repository, which is worth checking on a project that uses that name for something else.
The remaining rules cover plugin leftovers: atlassian-ide-plugin.xml, fabric.properties, crashlytics.properties, crashlytics-build.properties and com_crashlytics_export_strings.xml. Those last few can contain identifiers tied to a crash reporting account, which is a better reason to ignore them than tidiness. They are also generated during a build rather than written by hand, so nothing is lost by keeping them out of the repository entirely.
Examples
.idea/
*.iml
*.iws
*.ipr
out/
.idea_modules/
atlassian-ide-plugin.xml
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties11 lines exactly as the tool writes them, before any common additions you tick.
Things that catch people out
- Ignoring .idea wholesale also drops the shared code style and inspection profiles. Move formatting rules into a tool config file so they survive the decision.
- .idea/ here is written without a trailing star, so no negation can rescue anything inside it. If you want to share one file from the directory, you must change the rule to .idea/* first.
- Some project generators write a .idea directory before the first commit. Check git status --ignored on a fresh clone to see what is being hidden.
Try it: .gitignore Generator
Pick one or more templates, tick the common additions you want, and copy or download the combined .gitignore.
.gitignore Generator
LOCAL · Browser-OnlyGenerate comprehensive .gitignore files by combining templates for languages, frameworks, IDEs, and operating systems
Language
Framework
IDE
OS
Build Tool
Infrastructure
Common Additions
Preview
Select templates or common additions to generate a .gitignore file.
Related .gitignore templates
All .gitignore templates →VS Code .gitignore template
This template ignores the .vscode folder's contents but keeps five files back on purpose, which is the clearest statement of the commit or ignore argument.
Android Studio .gitignore template
The Android Studio template ignores local.properties, which names the SDK path on one machine, along with build output, captures and native build directories.
Eclipse .gitignore template
The Eclipse template ignores the project descriptor, classpath file and settings folder, which is right for a build tool project and wrong without one.
Vim .gitignore template
The Vim template uses character ranges to catch every swap file extension the editor cycles through, plus sessions, undo history and the netrw history.
Emacs .gitignore template
The Emacs template covers tilde backup files, the hash delimited auto save files, the symbolic lock files and compiled Lisp, plus per project tooling state.
Sublime Text .gitignore template
The Sublime template separates the project file from the workspace file, and covers sftp-config.json, which stores upload credentials in plain text.
Tools for this
- .gitignore Generator Generate .gitignore files for any project - 50+ templates for languages, frameworks, IDEs, and OS