This is just a very low-effort regurgitation of this: https://git-scm.com/docs/gitignore
Hey, come on now - they added 'check-ignore' which is good complementary advice.
You made my day. Everything is said and explained there.
Ok, sometimes a more vivid and visually explanatory style would help, but here still Google is your friend for individual concepts.
One of the best resources there is. git is a hell of a tool. It looks simple but is so beautifully versatile without being complex or not deductive.
Submit that link to Hacker News, and see how far it gets!