Main purpose of .gitignore:
- I'm telling git: "Git, do not upload any files I list in my .gitignore file:"
Use case
I have unencrypted private keyse.g. unencrypted private keys- I definitely do not want upload unencrypted keys to Github. This is a good time to add those files to your .gitignore file. This means they will never be "checked in".
I have a lot of personal notes / scribbles in certain open source repositories: they are useful to me but not for anyone else.
I would not want it uploaded to github because it would simply confuse everyone who reads it. The good thing is that I can ask git to "ignore" those files.
In my case, since I don't want to pollute the open source repository with my .gitignore files, I add it to a global .gitignore file.
The only cost to this approach is that I will not be able to recover those notes if my computer crashes etc.