Reputation: 16211
I am having issues with the .iml files generated by Android Studio. On a Gradle sync, they are regenerated meaning I then have to do a commit even if nothing has changed. I just want to make these files untracked.
I have tried the following things.
*.iml
to my project's .gitignore
file as well as each module's .gitignore
. I have tried both *.iml
and **/*.iml
git rm --cached app/app.iml
when they appear in the staged files list. Even after doing this and committing it, they appear as staged again later on.Upvotes: 31
Views: 35020
Reputation: 12615
You have the right steps, but you need to organize them
git rm --cached <all_your_iml_files>
to remove all of them from
the remote repository.
Alternatively you can do a simple command to delete all the *.iml
files like
git ls-files | grep "\.iml$" | xargs git rm --cached
Commit that change using git commit -m "msg"
and after that, you can see all your *.iml
files as untracked files.
*.iml
to your .gitignore file and commit it in a separate commit or in the same previous commit.Upvotes: 44
Reputation: 978
cd into project directory, git checkout and pull master branch
cd /home/your_user/project_directory
git checkout master
git pull origin master
edit .gitignore
file to insert *.iml
git rm --cached **/*.iml
git commit -a -m "rm all *.iml, update .gitignore"
git push origin master
I was working on another maven & Java git project using Idea IDE and it seems to add *.iml in many of the child directories.
The glob syntax **/*.iml
will cover all iml files in all directories within the current working directory.
Upvotes: 11