A .gitignore file is a plain text file where each line contains a pattern for files/directories to ignore. Normally, this is placed in the root directory of your repository. This is the recommended way. The patterns in the .gitignore file are relative to the location of the file.
Easiest pattern is a literal file name:
This will ignore any files named .DS_Store which is common in MacOS.
You can ignore entire directories by including their paths and putting a / at the end:
If you leave the slash ‘ / ‘ at the end you will match both directories and file names.