Cannot ignore .idea/workspace.xml - keeps popping up

Valentin Despa picture Valentin Despa · Nov 14, 2013 · Viewed 104k times · Source

Using PHPStorm, I am trying to ignore the workspace.xml which pops up every-time I try to make a git commit.

My .gitignore looks like:

/.idea/
.idea/workspace.xml

Because at a point the file was committed, I've also executed:

git rm --cached .idea/workspace.xml and then committed the removal, pushed to a bare repo.

But the file keeps popping up later when I do changes in the project.

Any ideas on what I am missing?

Answer

amerdidit picture amerdidit · Jan 21, 2015

I was facing the same issue, and it drove me up the wall. The issue ended up to be that the .idea folder was ALREADY commited into the repo previously, and so they were being tracked by git regardless of whether you ignored them or not. I would recommend the following, after closing RubyMine/IntelliJ or whatever IDE you are using:

mv .idea ../.idea_backup
rm .idea # in case you forgot to close your IDE
git rm -r .idea 
git commit -m "Remove .idea from repo"
mv ../.idea_backup .idea

After than make sure to ignore .idea in your .gitignore

Although it is sufficient to ignore it in the repository's .gitignore, I would suggest that you ignore your IDE's dotfiles globally.

Otherwise you will have to add it to every .gitgnore for every project you work on. Also, if you collaborate with other people, then its best practice not to pollute the project's .gitignore with private configuation that are not specific to the source-code of the project.