I am having the same issue. What I tried before was to add **/.iml in my .gitignore and all .iml files showed up in untracked files. I changed **/.iml into *.iml and it worked and disappeared in untracked files. Hope this helps.