I am using Git in Android Studio on a OS X machine, and I would like to have a personal .gitignore
file that overrides the .gitignore
that are in the project (I want mine to ignore .iml
files). Can this be done and how?
I have tried to create a .gitignore
file in my home dir with the following lines in:
# Android Studio
.*.iml
*.iml
And the I have used this command to make git use my file git config --global core.excludesfile ~/.gitignore
, but it does not work.
Any ideas?
Instead of creating a new .gitignore
file, you should use the .git/info/exclude
file to setup ignore rules specific to your clone of the repo.
So, basically, go to your project root, and run
cd $PROJECT_ROOT
echo "*.iml" >> .git/info/exclude
Note that the the pattern *.iml
will take care of files of kind .*.iml
as well, so you can make do with one ignore rule.
Also, this complements the existing ignore rules in .gitignore
and ignore rules of .gitignore
will still be applied.
It seems you are already tracking the .iml
files in your Git repo, so you can try removing them from Git using
git rm -r *.iml
git commit -m "removed *.iml"
Note that this will untrack them from the master repository as well once you do a push.
Otherwise, you can use git update-index --assume-unchanged <filename>
to ignore changes to those files locally.
And afterwards, the gitignore rules should work all right.