We're inside a directory called Utility Functions, which is a git repo. Our working directory is currently clean and our project contains exactly what we would expect. There are a few files as well as .git folder.
There are some types of programs that can automatically generate files we may not want in our git repo. For example, let's open up this folder, inside of the Mac OS X Finder. If I make a change in this program, it automatically generates this new .dsstore file.
Back in our command line, if we run GetStatus, it recognizes that there's a new on track. We don't to include user specific or automatically generated files or folders in our repo though. What we can do is create a new file called a .gitignore, not to open that in our code editor, now we can add our our .dsstore file type to our gitignore file. This will tell git that we don't want to track any files that match this pattern.
Let's save and close this file and go back to our command line. Now, if we run GetStatus, we see that see that our dsstore file is no longer included in the tracked files and we're free to commit and push this gitignore file as normal.
If we had already started tracking a file or folder before we added it to our gitignore, only to run gitrm--cached in order to clear the git cache, to remove the tracked files...
Going back to our gitignore file, there are many different types of patterns of files and folders that you may want to ignore in your projects. Here are a few examples. The .dsstore files automatically generated by Mac OS X Finder, Windows automatically generates a thumbs.db file, certain editors automatically generate files and folders such as .ida or .sublimeworkspace. This one I've added an asterisk to because we want to glob or match all patterns that come before this pattern.
We also may want to ignore files and folders automatically generated by package managers such as node modules or npm debug. We may also want to remove binary files like .png or remove cache folders that are automatically created from a script.
As you can see, there are many different types of files and folders that we could ignore from our projects. What you choose to add to you gitignore will be different depending on the project and what type of technology you're working with.
The bottom line is that generally you shouldn't include anything that's automatically generated or that's user specific in your git repos because it can clutter your git diffs and your remote storage.