Cannot ignore .idea/workspace.xml - keeps popping up
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"
Related videos on Youtube
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, 2021Comments
-
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 over 9 yearsTried everything below, added to gitignore, but it still keeps coming back, ignoring gitignore.
-
Luca Ballore about 8 yearsLooks like this same question. Check it out and see...
-
Luca Ballore about 8 yearsChek out this link: stackoverflow.com/questions/8156299/…. Looks like your same problem.
-
-
Godsmith over 9 yearsOr, 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 over 9 yearsWhile 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 about 9 yearsThe last command should be "mv ../.idea_backup .idea" instead of "git mv ../.idea_backup .idea" to avoid git error
-
MainActivity over 8 yearsI have to do
git rm .idea
instead ofgit add .idea
to do the job -
Luca Ballore about 8 yearsChek out this link: stackoverflow.com/questions/8156299/…. Looks exactly like your same problem.
-
jmendiola about 8 yearsI also changed
add
forrm
but in my case I had to add-r
as well to recursively remove all.git rm -r .idea
-
LoreV about 8 yearsI would also add, only for precision sake, that Idea intellij should be closed when doing this steps.
-
Srneczek over 7 yearsshut 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 over 7 yearsWow... 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 about 7 yearsThanks! many, many time spent looking for a working solutions and tried severals. This is the simplest way to do that.
-
Joe about 7 yearsThis works for anything in your .gitignore that is already tracked.
-
Skelly1983 almost 7 yearsFound 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 over 6 yearsMonths later... I tried this and it worked. I believe this should marked as the answer.
-
Hosang Jeon almost 6 yearsThank you! It's very helpful but I would want to change
rm .idea
torm -rf .idea
. -
Manius about 2 yearsWow, do people still actually waste their time with this stuff? Something like GitKraken can get this done for you in a second.