Why you should ignore files globally? - You shouldn’t but who can stop you!?
Some IDE and text editors stores cache or file index in project directory. These files are very often commited to remote repository. Way too often.
Ignore them once and for all!
Just remember it works only on your machine and won't be propagated to remote repository.
Create new global .gitignore file
Filename and directory doesn’t matter.
$ vim ~/.global_gitignore
Put in all not wanted files
You can place any entry you want as you do in normal .gitignore file. But make it slim and use only for most frequent and annoying files.
For example for files which occures only on your machine.
- You are the only MacBook user in team? - Everybody hates .DS_store!
- Maybe you are the only one who uses PyCharm or WebStorm or whatever else JetBrains has created? - Everybody hates .idea directory!
# macOS .DS_store # IDE .idea/ .vs_code/ # temporary backup which should not be committed *.old.* *.backup.* # my own tools which helps me, but not fit in project *_pawelzny.*
Do not put comments in the same line as rule because git will treat them as integral part of the rule.
# comment rule
rule # comment
Add the file to git config
$ git config --global core.excludesfile "~/.global_gitignore"
This command works for Windows too, but require absolute path to file ie.