You want certain files to be ignored when you do a "git add --all". Later you want to run a "git commit" and a "git origin push master" but you do not want certain files included. While developing a solution and modifying files, you place binary files or change source code to include sensitive passwords in the same directory as your locally saved Git repo that you pulled down. These files to be excluded are files you do not want stored in a Git repository on the centrally available server (e.g., BitBucket or GitHub). How does the .gitignore file help you keep files private that should not be stored in a repository while also being in a convenient location that allows you to develop solutions rapidly?
There are multiple settings and variations of how to use a .gitignore file. A basic way to use it is to create a .gitignore file (via vi) in a base directory of the Git repo. Then have a list of the file names that you do not want to include in the Git repository. List the files case sensitively and one file per line. If your repository has subdirectories, files that have the same name as those in the .gitignore file will all be excluded (regardless if they are in the base, or root, directory of the Git repo or in a subdirectory).