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

114,778

Solution 1

I had to:

  • remove the file from git
  • push the commit to all remotes
  • make sure all other committers updated from remote

Commands

git rm -f .idea/workspace.xml
git remote | xargs -L1 git push --all

Other committers should run

git pull

Solution 2

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.

Solution 3

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)

Solution 4

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

Solution 5

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"
Share:
114,778

Related videos on Youtube

Valentin Despa
Author by

Valentin Despa

Hello there, thanks for checking my profile page. I am dedicated software developer and open source lover. Interested in databases and tech stuff: PHP, Java, MySQL / MariaDB, JavaScript, Angular.

Updated on July 26, 2021

Comments

  • Valentin Despa
    Valentin Despa almost 3 years

    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?

    • Olaf
      Olaf over 9 years
      Tried everything below, added to gitignore, but it still keeps coming back, ignoring gitignore.
    • Luca Ballore
      Luca Ballore about 8 years
      Looks like this same question. Check it out and see...
    • Luca Ballore
      Luca Ballore about 8 years
      Chek out this link: stackoverflow.com/questions/8156299/…. Looks like your same problem.
  • Godsmith
    Godsmith over 9 years
    Or, to add the row to .gitignore, just type echo .idea/workspace.xml>>.gitignore. You don't need to open vi for everything. Alternatively, and what would I would do, is to have a separate .gitignore file in the .idea directory: echo workspace.xml>>.idea/.gitignore
  • flyingace
    flyingace over 9 years
    While I'm glad for this answer, I can't help but feel that it would be more useful if the instructions of how to accomplish the steps (eg, command line directives) were included.
  • Leo Caseiro
    Leo Caseiro about 9 years
    The last command should be "mv ../.idea_backup .idea" instead of "git mv ../.idea_backup .idea" to avoid git error
  • MainActivity
    MainActivity over 8 years
    I have to do git rm .idea instead of git add .idea to do the job
  • Luca Ballore
    Luca Ballore about 8 years
    Chek out this link: stackoverflow.com/questions/8156299/…. Looks exactly like your same problem.
  • jmendiola
    jmendiola about 8 years
    I also changed add for rm but in my case I had to add -r as well to recursively remove all. git rm -r .idea
  • LoreV
    LoreV about 8 years
    I would also add, only for precision sake, that Idea intellij should be closed when doing this steps.
  • Srneczek
    Srneczek over 7 years
    shut down IDE \n git rm -f .idea/workspace.xml \n git commit -m "removing workspace.xml" \n edit .gitignore to exclude workspace.xml \n open IDE
  • Jonny Asmar
    Jonny Asmar over 7 years
    Wow... thank you!! Tried this a million different ways to no avail. THIS is the correct step by step approach. The key difference that I was missing was to make sure my IDE was closed - don't miss that step! Excellent answer :)
  • edepe
    edepe about 7 years
    Thanks! many, many time spent looking for a working solutions and tried severals. This is the simplest way to do that.
  • Joe
    Joe about 7 years
    This works for anything in your .gitignore that is already tracked.
  • Skelly1983
    Skelly1983 almost 7 years
    Found no solution to this, until reading this, thanks for the solution. Although ensure you have no stashes of the .idea folder as this would require you to delete the stash.
  • iVoidWarranties
    iVoidWarranties over 6 years
    Months later... I tried this and it worked. I believe this should marked as the answer.
  • Hosang Jeon
    Hosang Jeon almost 6 years
    Thank you! It's very helpful but I would want to change rm .idea to rm -rf .idea.
  • Manius
    Manius about 2 years
    Wow, do people still actually waste their time with this stuff? Something like GitKraken can get this done for you in a second.