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
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
.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:
Write the files you need to be ignored, and .idea/ too. To be sure it will be ignored I put the following:
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.
Source: Stackoverflow.com