Can I add a .gitignore file only for me, which overrides the .gitignore project?

I use Git in Android Studio on an OS X computer, 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 tried to create a .gitignore file in my home directory with the following lines in:

 # Android Studio .*.iml *.iml 

And I used this command to make Git my git config --global core.excludesfile ~/.gitignore file git config --global core.excludesfile ~/.gitignore , but it does not work.

Any ideas?

+8
git android-studio gitignore
source share
1 answer

Instead of creating a new .gitignore file .gitignore you should use the .git/info/exclude file to configure to ignore the rules specific to your repo clone.

So basically go to your project root and run

 cd $PROJECT_ROOT echo "*.iml" >> .git/info/exclude 

Note that the *.iml template will also take care of files of the form .*.iml , so you can do this with a single ignore rule.

In addition, this complements the existing ignore rules in .gitignore , and the ignore rules .gitignore will apply.


It seems you are already tracking .iml files in your Git repository, so you can try removing them from Git with

 git rm -r *.iml git commit -m "removed *.iml" 

Please note that this will also eliminate them from the main repository as soon as you click.

Otherwise, you can use git update-index --assume-unchanged <filename> to ignore changes to these files locally. And after that, gitignore rules should work fine.

+9
source share

All Articles