phpstorm is too aggressive in adding .idea to the git index
This seems like a bug to me, but perhaps it's intentional. The setup is that I have created a new project and created a php file in that project. I want to import the project into a new git repo but I don't want to track anything in the .idea directory. I have not created a .gitignore file yet. Next, I start to make my initial commit of the project and I see the following dialog:
Upon seeing that I realize I do not want to track anything in the idea directory so I cancel the dialog and create a .gitignore file with .idea/ in it. But it is too late. Just by bringing up the above dialog the files in .idea are added to the index. They are added without waiting for any interaction. The following line appears in the git console as the dialog is displayed:
11:23:28.874: [GitPlayground] git -c credential.helper= -c core.quotepath=false -c log.showSignature=false add --ignore-errors -A -- .idea/php.xml .idea/.gitignore .idea/GitPlayground.iml
I believe to fix this I have to manually run git rm --cached on each file incorrectly added.
Interestingly, this does not always happen. As more files are added to the .idea/ directly this problem no longer happens.
Please sign in to leave a comment.
What option do you have chosen at Preferences | Version Control | When files are created? Also, what PhpStorm version are you using?
Version is PhpStorm 2020.1. My apologies Eugene as I cannot find the "When Files are created option", but here are a couple of screenshots of the options that might help:
My apologies, I missed one step: Preferences | Version Control | Confirmation | When files are created.