What to gitignore from the .idea folder?
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
The .idea folder mixes two very different kinds of files: project settings that may be useful to share and personal workspace state that should almost never be committed. The right .gitignore strategy is therefore selective, not "ignore the whole folder" by default. In team projects, the goal is to keep shared project metadata while excluding user-specific IDE noise.
What Usually Should Be Ignored
Files that describe your personal working session, machine-local resources, or temporary IDE state should usually stay out of Git.
Common examples include:
- '
.idea/workspace.xml' - '
.idea/tasks.xml' - '
.idea/shelf/' - '
.idea/usage.statistics.xml' - '
.idea/dataSources/' - '
.idea/dataSources.local.xml' - '
.idea/**/contentModel.xml'
These files often contain open tabs, local database connections, window layouts, or machine-specific paths. Committing them usually creates noise and merge conflicts without helping the team.
What Is Often Worth Keeping
Some .idea files can be useful to share because they define actual project behavior.
Examples that teams often keep include:
- '
.idea/misc.xml' - '
.idea/modules.xml' - '
.idea/vcs.xml' - '
.idea/codeStyles/' - '
.idea/inspectionProfiles/' - selected
.idea/runConfigurations/
These can help standardize the project SDK, code style, inspections, version-control mapping, and shared run configurations.
The right answer still depends on the team. If run configurations include developer-specific paths or secrets, they should not be committed even though the folder itself can be useful in principle.
A Practical .gitignore Example
A common compromise is to ignore the personal files and keep the project-level ones.
This approach assumes your team has agreed that the unignored files are safe and useful to share.
Why Ignoring The Entire .idea Folder Is Sometimes Fine
Some teams avoid the question entirely and ignore the whole .idea folder. That is a reasonable choice when:
- the project is already fully described by build files
- developers use different IDEs
- team-specific IntelliJ settings are not important
- merge churn in
.ideafiles has become annoying
In that case, the .gitignore rule is simple:
This is blunt but effective.
Let The Build System Carry The Real Project Definition
A healthy project should not depend on arbitrary IDE files for its core behavior. Maven, Gradle, npm, Poetry, or similar project files should describe the build, dependencies, and test execution.
That way, the question of .idea sharing becomes a convenience choice rather than a source of project fragility.
Common Pitfalls
The most common mistake is committing workspace.xml. That file is notoriously personal and tends to produce useless diffs.
Another issue is ignoring the entire .idea folder without checking whether the team actually wants to share inspections, code style, or run configurations.
It is also easy to commit machine-specific data source files that contain local paths or connection details. Those rarely belong in version control.
Finally, do not assume every project should follow the same rule. A solo project, a polyglot team, and a Java-only IntelliJ team may reasonably choose different .idea strategies.
Summary
- Ignore user-specific
.ideafiles such asworkspace.xml,tasks.xml, and local data source files. - Consider keeping shared project settings such as code styles and inspection profiles.
- Ignore the whole
.ideafolder if your team does not benefit from sharing IDE metadata. - Keep build and dependency truth in project files, not in IDE state.
- Choose a
.gitignorestrategy deliberately instead of treating.ideaas all-or-nothing by default.
Related reading
- What would I use git-worktree for?
- What's the -practical- difference between a Bare and non-Bare repository?
- What's the best visual merge tool for Git?
- What's the correct way to check if it's possible to perform a fast-forward merge with git merge-base?
- What's the difference between commit and apply in SharedPreferences
- What's the difference between git clone --mirror and git clone --bare
- What's the difference between git diff --patience and git diff --histogram?
- What's the difference between 'git merge' and 'git rebase'?
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.