Spring Boot .gitignore template
The Spring Boot template covers Maven and Gradle output together, plus editor state for three different IDEs, and says nothing about application configuration secrets.
At a glance
- Category
- Framework
- Patterns in this template
- 26 rules, plus 3 comment lines
- Directories ignored
- 8 of the 26 rules end in a slash, so they match directories only
- Re-include rules
- 6 lines start with ! to keep something back
- Also needs an OS template
- Yes. This template covers editors thoroughly and the operating system not at all.
- Typical companions
- An OS template. The build tool and IDE rules are already included here.
In detail
This template hedges on the build tool. target and the Maven wrapper negation cover one, while .gradle, build and the Gradle wrapper negation cover the other, so a project gets the right rules without anyone choosing. The cost is a handful of rules that will never match anything in your repository, which is harmless.
The two wrapper negations are the same idea in both ecosystems. Ignoring *.jar would also catch the wrapper jar, which is the small bootstrapper committed on purpose so that a clone can build without the build tool installed. Both negations put it back, and both are the reason those broad archive rules are safe.
HELP.md is the getting started file the project generator writes into a new project. It contains links to documentation for the starters you selected and nothing project specific, so most teams delete it rather than ignore it, but the rule catches it either way.
The editor sections cover three tools. The first covers a set of Eclipse based files: .classpath, .project, .settings, .factorypath, .apt_generated and .springBeans. The second covers .idea plus *.iml, *.iws and *.ipr. The third covers the NetBeans directories. Comment lines separate them, which is why this template renders with section headers.
What is missing is the thing most likely to leak. Application configuration lives in a properties or YAML file under src/main/resources, and a local profile variant holding a real database password is a normal thing to have. Nothing here ignores it, so add a rule for your local profile file yourself.
Examples
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
.gradle/
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/29 lines exactly as the tool writes them, before any common additions you tick.
Things that catch people out
- No rule here covers application-local.properties or application-local.yml. If you keep a local profile with real credentials, add the rule or it will be committed.
- .idea is ignored without a trailing slash, so it matches both a file and a directory of that name. That is fine in practice but broader than the IntelliJ template's own rule.
- The template ignores /dist and /nbdist anchored to the root only, so a module level dist directory in a multi module build is not covered.
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 →Java .gitignore template
What the Java .gitignore template ignores: compiled classes, packaged archives, crash dumps, and the negations that keep the Gradle wrapper jar tracked.
Maven .gitignore template
The Maven template ignores the target directory and the backup files the release plugin leaves behind, including the wrapper jar that Gradle keeps.
Gradle .gitignore template
Six rules covering the Gradle cache and build directories, with negations that keep the wrapper jar and properties tracked because a clone needs both.
.NET .gitignore template
The .NET template covers bin, obj and NuGet output, and ignores launchSettings.json, which holds the launch profiles and environment variables for local runs.
Flutter .gitignore template
The Flutter template adds generated plugin manifests and per platform build artefacts to the Dart rules, including the iOS pod directory and build modes.
Unity .gitignore template
The Unity template ignores the import cache, temporary build state and the IDE project files the editor regenerates, using bracket classes for case safety.
Tools for this
- .gitignore Generator Generate .gitignore files for any project - 50+ templates for languages, frameworks, IDEs, and OS
- GitHub Actions Generator Free online github actions generator - generate CI/CD workflow YAML files from templates