[git] Cannot ignore .idea/workspace.xml - keeps popping up

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?

This question is related to git intellij-idea phpstorm

The answer is


Ignore the files ending with .iws, and the workspace.xml and tasks.xml files in your .gitignore Reference


To remove .idea/ completely from the git without affecting your IDE config you could just do:

git rm -r --cached '.idea/'
echo .idea >> .gitignore
git commit -am "removed .idea/ directory"

In the same dir where you see the file appear do:

  • rm .idea/workspace.xml
  • git rm -f .idea/workspace.xml (as suggested by chris vdp)
  • vi .gitignore
  • i (to edit), add .idea/workspace.xml in one of the lines, Esc, :wq

You should be good now


I had this problem just now, I had to do git rm -f .idea/workspace.xml now it seems to be gone (I also had to put it into .gitignore)


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.


Just tell git to not assume it is changed never matter what:

git update-index --assume-unchanged src/file/to/ignore

yes, you can remove the files from the git repository. But if your team all use the same IDE or you are by yourself, you probably don't want to do that. For yourself, you want to have an ok starting point to resume working, for your teammates as well.


The way i did in Android Studio which is also based on IntelliJ was like this. In commit dialog, I reverted the change for workspace.xml, then it was moved to unversioned file. After that I deleted this from commit dialog. Now it won't appear in the changelist. Note that my gitignore was already including .idea/workspace.xml


If you have multiple projects in your git repo, .idea/workspace.xml will not match to any files.

Instead, do the following:

$ git rm -f **/.idea/workspace.xml

And make your .gitignore look something like this:

# User-specific stuff:
**/.idea/workspace.xml
**/.idea/tasks.xml
**/.idea/dictionaries
**/.idea/vcs.xml
**/.idea/jsLibraryMappings.xml

# Sensitive or high-churn files:
**/.idea/dataSources.ids
**/.idea/dataSources.xml
**/.idea/dataSources.local.xml
**/.idea/sqlDataSources.xml
**/.idea/dynamic.xml
**/.idea/uiDesigner.xml

## File-based project format:
*.iws

# IntelliJ
/out/

Since in my case I was performing a first commit of a project, simply deleting .git and .idea folders and then reinitializing git using git init helped to solve a problem. Now I don't have .idea at all.


Same problem for me with PHPStorm

Finally I solved doing the following:

  • Remove .idea/ directory
  • Move .gitignore to the same level will be the new generated .idea/
  • Write the files you need to be ignored, and .idea/ too. To be sure it will be ignored I put the following:

    • .idea/
    • .idea
    • .idea/*

I don't know why works this way, maybe .gitignore need to be at the same level of .idea to can be ignored this directory.


Examples related to git

Does the target directory for a git clone have to match the repo name? Git fatal: protocol 'https' is not supported Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) git clone: Authentication failed for <URL> destination path already exists and is not an empty directory SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 GitLab remote: HTTP Basic: Access denied and fatal Authentication How can I switch to another branch in git? VS 2017 Git Local Commit DB.lock error on every commit How to remove an unpushed outgoing commit in Visual Studio?

Examples related to intellij-idea

IntelliJ: Error:java: error: release version 5 not supported Has been compiled by a more recent version of the Java Runtime (class file version 57.0) Error: Java: invalid target release: 11 - IntelliJ IDEA IntelliJ can't recognize JavaFX 11 with OpenJDK 11 Error: JavaFX runtime components are missing, and are required to run this application with JDK 11 ERROR Source option 1.5 is no longer supported. Use 1.6 or later Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6 How to configure "Shorten command line" method for whole project in IntelliJ intellij idea - Error: java: invalid source release 1.9 Failed to resolve: com.google.android.gms:play-services in IntelliJ Idea with gradle

Examples related to phpstorm

Difference between WebStorm and PHPStorm Cannot ignore .idea/workspace.xml - keeps popping up JetBrains / IntelliJ keyboard shortcut to collapse all methods Can IntelliJ IDEA encapsulate all of the functionality of WebStorm and PHPStorm through plugins? Word wrapping in phpstorm How to display hidden characters by default (ZERO WIDTH SPACE ie. &#8203) How to make phpstorm display line numbers by default? How do you debug PHP scripts?