Removing uneccessary files

How does .gitignore work?