Hello everyone!

We have been investing plenty of personal time and energy for many years to share our knowledge with you all. However, we now need your help to keep this blog running. All you have to do is just click one of the adverts on the site, otherwise it will sadly be taken down due to hosting etc. costs. Thank you.

The global .gitignore file with set of rules is created to ignore files and folders in every git repositories in your system so it applies to all the projects you're working on. Files to be globally ignored must not be indexed before otherwise global ignore won't work for them.


Check what has to be ignored


As we can see below, there is a useless folder .idea/ which needs to be ignored.


inanzzz@inanzzz:~/project$ git branch
* develop
master
inanzzz@inanzzz:~/project$ git status
On branch develop
Untracked files:
(use "git add ..." to include in what will be committed)

.idea/

nothing added to commit but untracked files present (use "git add" to track)

Create global .gitignore file


To make sense, I'm using a descriptive name which is .gitignore_global so you're free to name it as you want. Create the file in your home directory, put .idea/ into it, save it and exit.


inanzzz@inanzzz:~$ sudo nano .gitignore_global

Setup global configuration file


Setup global configuration file "core.excludesfile" to point to your new global .gitignore_global file.


inanzzz@inanzzz:~$ echo $HOME
/home/inanzzz
inanzzz@inanzzz:~$ git config --global core.excludesfile /home/inanzzz/.gitignore_global

Check if it worked or not


As we can see below, .idea/ folder has been ignored completely.


inanzzz@inanzzz:~/project$ git branch
* develop
master
inanzzz@inanzzz:~/project$ git status
On branch develop
nothing to commit, working directory clean