I have .idea in gitignore, but it is still in local changes

How can I fully gitignore the .idea folder?

I have .idea in gitignore, but it is still in local changes.

Here is my .gitignore file:

# Created by https://www.gitignore.io/api/webstorm,meteorjs,node

### WebStorm ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff:

# Sensitive or high-churn files:

# Gradle:

# Mongo Explorer plugin:

## File-based project format:

## Plugin-specific files:

# IntelliJ

# mpeltonen/sbt-idea plugin

# JIRA plugin

# Crashlytics plugin (for Android Studio and IntelliJ)

### WebStorm Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721

# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr

### MeteorJS ###
# default meteor build and local packages

# meteor settings file

# meteor build output files

# general swp files from vim

### Node ###
# Logs

# Runtime data

# Directory for instrumented libs generated by jscoverage/JSCover

# Coverage directory used by tools like istanbul

# nyc test coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)

# node-waf configuration

# Compiled binary addons (http://nodejs.org/api/addons.html)

# Dependency directories

# Optional npm cache directory

# Optional eslint cache

# Optional REPL history

# Output of 'npm pack'

# Yarn Integrity file

Comment actions Permalink

I ran into this problem today and found this thread, which doesn't seem to have a clear answer.  I had the preexisting files in my repo and needed to remove them, but the IDE kept showing my .idea/ files as changed in the Local Changes.  I was able to fix this by closing all instances of the IDE, then running `git rm --cached -r .idea`. I did this on each branch that I was working on and pushed those changes up to my repo.  Then I reopened the IDE and the issue was gone.  Hope this helps.

Comment actions Permalink

In Git, it is only possible to ignore unversioned files. If a file is already tracked in git, it is not possible to ignore it. You need to stop tracking it in git, which can be done using git rm --cached command. After committing this change, files should go ignored, since there is a rule to ignore them already. See https://stackoverflow.com/questions/1274057/how-to-make-git-forget-about-a-file-that-was-tracked-but-is-now-in-gitignore, for example

And no, it's not a problem with PhpStorm, it's git own behavior

Comment actions Permalink

You must have added these files to the repository already... .gitignore is not used when selecting files to commit, it's used for adding only: files listed there are not suggested to be added. But, once they are added, they appear in Local Changes

Comment actions Permalink

I can confirm this.  PyCharm 2017.3.3 honors the .gitignore file for any other type of file except those in .idea.  I have to uncheck the files in that directory every time I do an add/commit.  I need to ignore these files because I have a repo I share with multiple sites that need to have different local IDE configurations.  Would be nice if it would also honor .gitignore for .idea/ if it is specified.  git add * does not have this issue from the command line.

Comment actions Permalink

EVERY other Git gui does not do this, sorry. It's an undesired behavior by PHPStorm. You won't find this behavior on SourceTree for instance. 

Comment actions Permalink

Yea, I don't think we are speaking the same language. EVERY other Git GUI I have used - SourceTree, Tower, GitKraken ignores files in .gitignore - as they should. It is only in PHPStorms VCS that I see these ignored files. It's a downside of using PHPStorm and something that is just inevitable. Until PHPStorm better immolates better Git management tools, it will just be janky.  

Comment actions Permalink
git status -s -uno | wc -l


PhpStorm Local Changes 58 files

Ok JetBrains - you do you. 

Comment actions Permalink

There appears to be some effort to work on this now - someone _might_ be listening! But on the whole PHPStorm .gitignore functionality still sucks so bad compared to any commonly used git GUI. See this comment (They admit to a 'bug'! #winning) https://intellij-support.jetbrains.com/hc/en-us/community/posts/360000276420/comments/360000418180

Comment actions Permalink

If someone still has the same issue, then it is worth checking the .idea/workspace.xml file.
They might be in project > component "ChangeListManager" > list name="Default Changelist"
For me deleting the rows reflecting those files was enough to clear it up. 

Comment actions Permalink

Same issue here.... Files were all new and .gitignore was ignored. I had to manually go delete the files from .idea/workspace.xml file to solve the issue. This is definitely a BUG that should get fixed!

Comment actions Permalink

Yes, I did.

How can I remove them from the repository or fix this issue in some other way?

Comment actions Permalink

You can use "git rm –cached <file>" to remove file from the repository, preserving its local version. Unfortunately there is no way to perform this action in UI

Comment actions Permalink

I ran `git rm ~/devel/flt/.idea/workspace.xml` and `git rm ~/devel/flt/.idea/workspace.xml --cached` and then commit and push. It is still showing in local changes.

Comment actions Permalink

hmm... and what does `git status` show?

Comment actions Permalink

.gitignore is respected - files listed there are not auto-added to Git. But, once you add them, they do appear in Local Changes

Comment actions Permalink

Yes, this is happening to me Git VCS totally sucks in PHPStorm. hehe. This issue is a true deal breaker. 

Comment actions Permalink

But I do think you have made very clear why this issue persists and why VCS is just bad in PHPStorm. So thank you for that at least. 

Comment actions Permalink

this is unacceptable and is causing us a lot of problems.

 this file cannot be ignored or removed and because of PhpStorm's bad code i can't work from home


since you refuse to fix it, i will have to vote with my wallet and find another IDE
Comment actions Permalink

I also had said problem. I had a project freshly ported over from eclipse and added the .idea folder to the .gitignore. To my disbelieve all files were already added to git as either new, or modified. When I removed them with git rm -r .idea -f, the project view crashed. After restarting IntelliJ, I was prompted to add the project as a Maven project. Thereafter, no files from the .idea folder were listed in git status.

Comment actions Permalink

Looks like as of 2019.2.4, there is now a .idea/.gitignore:

# Default ignored files

It must have generated this from when I first created the .gitignore, but ignores future .gitignore additions to ./idea after the first time reading .gitignore.  I wanted to add /webServers.xml to this file to stop it from suggesting to add it at each commit but it had no effect.  I also tried to use File -> Invalidate Caches / Restart but it also had no effect.

JetBrains, please either make sure that any changes to <project_root>/.gitignore will either invalidate this, or stop creating a cache altogether for this which seems more problematic than it's worth.  It's a *GIT* management interface.  There should be no other authority other than .gitignore to look for which files to suggest for a commit.  Any more being "smart" about this just adds negative value to an otherwise excellent interface.

I also see the bug https://youtrack.jetbrains.com/issue/IDEA-148109 returns a 404 now.  I'll be filing a new bug if I can't find any other reference to this issue in the bug tracker.

Comment actions Permalink


>I also see the bug https://youtrack.jetbrains.com/issue/IDEA-148109 returns a 404 now.

Just fix the URL and remove rubbish symbols at the end (as simple as that): https://youtrack.jetbrains.com/issue/IDEA-148109

Comment actions Permalink

I can't prove it but I believe this is happening from clicking "always add external changes" when asked.

Comment actions Permalink

This solved the issue for me -- I ran the command line `git rm --cached -r .idea` from the terminal. Then commit. I could delete the `.idea` folder. I already had .`idea/` in the .gitignore file. I could not find a way to do the whole process using UI though.

Comment actions Permalink

Yes, same here. Files added to .gitIgnore should be removed from changelist (and from repository).

Comment actions Permalink

I have a directory of almost 20k auto-generated files that ARE in .gitignore and are NOT tracked by git (git status doesn't show them), but they appear in the changelist in GoLand and I have no way to remove them in the UI, unless I use "revert", but then it reverts the auto generated local files, from what I can tell. 

Very strange.

Comment actions Permalink

I had this problem, the solution for me was to :

Open Settings - Go to Version Control, remove all the directories except mine.

There was some vendor directories listed after a composer update, even if my vendor is listed in .gitignore

Comment actions Permalink

As it's written above, .gitignore is not used when selecting files to commit, it's used for adding only: files listed there are not suggested to be added. But, once they are added, they appear in Local Changes. This is expected behavior, not specific to PhpStorm.


Please sign in to leave a comment.