Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove .iml Files From GIT for Good

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.

  • Added *.iml to my project's .gitignore file as well as each module's .gitignore. I have tried both *.iml and **/*.iml
  • Used 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.
  • As suggested here I added it to the Ignored Files in Settings under version control
like image 999
StuStirling Avatar asked Mar 02 '16 14:03

StuStirling


People also ask

Can I remove IML files?

In case you delete a module IML file, you can regenerate the file by rebuilding your project, reimporting your project, or opening and closing IDE. IML file is referenced and generated within IDEs. To open or edit . iml files, you need appropriate software.

What do I do with a .IML file?

IML is a module file created by IntelliJ IDEA, an IDE used to develop Java applications. It stores information about a development module, which may be a Java, Plugin, Android, or Maven component; saves the module paths, dependencies, and other settings.

What is .IML file in Git?

An IML file is a module settings file created by IntelliJ IDEA, an Integrated Development Environment (IDE) used to develop Java applications. It stores information about a development module, which is a Java, Plugin, Android, or Maven component of a Java application.


Video Answer


2 Answers

You have the right steps, but you need to organize them

  1. 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

  2. Commit that change using git commit -m "msg" and after that, you can see all your *.iml files as untracked files.

  3. Add *.iml to your .gitignore file and commit it in a separate commit or in the same previous commit.
like image 197
Ahmed Hegazy Avatar answered Oct 04 '22 21:10

Ahmed Hegazy


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.

like image 40
James T. Avatar answered Oct 04 '22 19:10

James T.