gitignore file is a text file that tells Git which files or folders to ignore in a project. A local . gitignore file is usually placed in the root directory of a project. You can also create a global . gitignore file and any entries in that file will be ignored in all of your Git repositories.
To stop tracking a file you need to remove it from the index. This can be achieved with this command.
$ git rm --cached <file>
If you want to remove a whole folder, you need to remove all files in it recursively.
$ git rm -r --cached <folder>