Eclipse .gitignore template
The Eclipse template ignores the project descriptor, classpath and settings files, plus the metadata directory and the backup and swap files older tooling leaves.
At a glance
- Category
- IDE
- Patterns in this template
- 16 rules
- Directories ignored
- 4 of the 16 rules end in a slash, so they match directories only
- Also needs an OS template
- Yes. This covers the editor and nothing beyond it.
- Typical companions
- Java, Maven or Gradle, since those are what generate the files being ignored.
In detail
.project and .classpath are the two files that define an Eclipse project: what it is called, which builders run on it, and where its sources and dependencies are. Whether ignoring them is right depends entirely on whether something else can regenerate them. A project built by Maven or Gradle can, because the build tool has an import step. A project with no build tool at all cannot, and ignoring these files means a clone has no project to open.
.settings is the per project preferences directory, holding compiler compliance level, formatter settings and per project overrides of workspace preferences. This is the folder with the strongest argument for being tracked, since a shared formatter setting prevents whitespace churn, and it is worth negating a specific file inside it if your team relies on one.
.metadata is the workspace metadata directory. It is not part of a project at all: it belongs to the workspace that contains projects, and it holds indexes, logs and plugin state. It only appears in a repository when someone has created the workspace inside the project folder, which is a mistake in itself.
bin is the default output directory for a project compiled by the editor rather than by a build tool. tmp and *.tmp are working files. local.properties holds machine specific paths, which is the same convention Android tooling uses and the same reason applies: it names directories that exist only on one machine.
The remaining rules cover editor debris: *.bak, *.swp and *~.nib are backup and swap files, *.launch is a saved run configuration, and .loadpath, .recommenders, .externalToolBuilders and *.pydevproject come from specific plugins. A saved run configuration is occasionally worth sharing, so if your team relies on one, add a negation for that specific file rather than dropping the whole rule.
Examples
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders
.classpath
.project
.externalToolBuilders/
*.launch
*.pydevproject16 lines exactly as the tool writes them, before any common additions you tick.
Things that catch people out
- If the project has no build tool that can regenerate .project and .classpath, ignoring them leaves a clone with nothing to import. Track them in that case.
- .settings is ignored wholesale, which throws away a shared formatter configuration. Consider negating the specific preference file your team relies on.
- bin/ is unanchored, so a directory of shell scripts called bin is ignored along with the compiler output this rule targets.
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 →IntelliJ IDEA .gitignore template
The IntelliJ template ignores the whole .idea directory and the module files, which is simpler than the alternative and loses some settings worth sharing.
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.
Spring Boot .gitignore template
The Spring Boot template covers both build tools at once and adds sections for three IDEs, which makes it broad but leaves application secrets uncovered.
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