When you're working with git, there are many types of files which you will want to ignore in every single git project. System files like .DS_Store or IDE files/folders like .idea. Those files are more related to your system then your project and should therefore be ignored in a global .gitignore file.

Just create a basic .gitignore file in (for example) your home directory ~/.gitignore and add those files to it.

.idea  
.DS_Store

Then just add it to your global git config with the following command:

$ git config --global core.excludesfile ~/.gitignore